This is the code I am using to plot stock price charts with mplfinance and I would like the graph to be log scaled. How can I accomplish this?
import mplfinance as mpf
# Data reading and processing steps omitted
mpf.plot(data, type='line')
This is the code I am using to plot stock price charts with mplfinance and I would like the graph to be log scaled. How can I accomplish this?
import mplfinance as mpf
# Data reading and processing steps omitted
mpf.plot(data, type='line')
Here's the solution I came up with:
import mplfinance as mpf
from matplotlib import pyplot as plt
# Data reading and processing steps omitted
fig, axlist = mpf.plot(data, type='line', returnfig=True)
ax = axlist[0]
ax.set_yscale('log')
plt.show()
@JakeBoggs worked, but then the text formatting was scientific notation. For anybody else who is looking into this, I would recommend converting the axis back using a ScalarFormatter
import mplfinance as mpf
from matplotlib import pyplot as plt
from matplotlib.ticker import ScalarFormatter
# Data reading and processing steps omitted
fig, axlist = mpf.plot(data, type='line', returnfig=True)
ax = axlist[0]
ax.set_yscale("log")
ax.yaxis.set_major_formatter(ScalarFormatter())
ax.yaxis.set_minor_formatter(ScalarFormatter())
plt.show()