如何使用新的mplfinance软件包编辑无花果? [英] How to edit the fig with the new mplfinance package?
问题描述
使用新的mplfinance,我似乎无法添加任何文本,旋转轴,更改背景颜色等.
I can't seem to add any text, rotate axis, change the background color, etc with the new mplfinance.
使用旧的 mpl-finance,我只做 fig, ax = plt.subplots()
并编辑 fig 和 ax 但是我想要:fig.text(0.96,1,某些文本",size = 9,fontweight ='bold',color ='black',ha ="right")
或 plt.legend(loc ='upper left')代码>
With the old mpl-finance, I just do fig, ax = plt.subplots()
and edit the fig and ax however I want to like: fig.text(0.96, 1, 'some text', size=9, fontweight='bold',color='black', ha="right")
or plt.legend( loc='upper left')
有谁知道如何使用新软件包来做到这一点?
Does anyone know how to do that with the new package?
推荐答案
要访问mplfinance的Figure和Axes对象,有两种方法:
方法一.调用plot时设置returnfig=True
:
fig, axlist = mpf.plot(data,...,returnfig=True,...)
axlist
将是与面板从上到下,每个面板有两个轴,其中第一个是主要em> 轴,下一个是 _secondary 轴.例如,如果您有3个面板,则 returnfig = True
将返回6个轴对象. axlist [0]
和 axlist [1]
将分别是面板 0 的主轴和辅助轴.axlist[2]
和 axlist[3]
将分别是面板 1 等的主轴和副轴.
axlist
will be a list of axes corresponding to the panels from top to bottom, two axes per panel where the first is the primary axes and the next is the _secondary axes. For example, if you have 3 panels then returnfig=True
will return 6 Axes objects. axlist[0]
and axlist[1]
will be the primary and secondary axes, respectively, for panel 0. axlist[2]
and axlist[3]
will be the primary and secondary axes, respectively, for panel 1, etc.
方法2.创建自己的Figure和Axes对象,并将它们传递给mplfinance.> 您可以在此处查看如何执行此操作的示例.强>
Method 2. Create your own Figure and Axes objects and pass these into mplfinance. You can see examples of how to do this here.
还请注意,当指定 x,y 坐标以定位文本、图例等时:
Please note also that, when specifying x,y coordinates for positioning of text, legends, etc. then:
如果 show_nontrading
kwarg 是 False
(即默认值,如果未指定)那么 x 轴值实际上不是日期,因为它们出现, 但是是数据框中从零到行数的整数值.
if show_nontrading
kwarg is False
(i.e. the default value if unspecified) then the x-axis values are not actually dates as they appear, but are integer values from zero up to the number of rows in your dataframe.
HTH
这篇关于如何使用新的mplfinance软件包编辑无花果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!