mplfinance 是否有对数刻度设置?

Is there a logarithmic scale setting for mplfinance?

这是我用来使用 mplfinance 绘制股票价格图表的代码,我希望图表按对数比例缩放。我怎样才能做到这一点?

import mplfinance as mpf

# Data reading and processing steps omitted

mpf.plot(data, type='line')

这是我想出的解决方案:

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 有效,但文本格式是科学记数法。对于任何正在研究这个的人,我建议使用 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()