簡體   English   中英

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()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM