这是我使用mplfinance绘制股票价格图表的代码,我希望图表是对数缩放的。我如何才能做到这一点呢?
import mplfinance as mpf
# Data reading and processing steps omitted
mpf.plot(data, type='line')发布于 2020-11-10 09:45:59
这是我想出的解决方案:
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()发布于 2021-01-06 09:53:11
@JakeBoggs有效,但文本格式是科学记数法。对于正在研究这一点的其他人,我建议使用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()https://stackoverflow.com/questions/64721265
复制相似问题