是否有对数刻度设置?

问题描述

这是我使用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,returnfig=True)
ax = axlist[0]
ax.set_yscale("log")
ax.yaxis.set_major_formatter(ScalarFormatter())
ax.yaxis.set_minor_formatter(ScalarFormatter())
plt.show()

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...