更改mplfinance图表样式时“ returnfig = true”在代码中的任何地方都没有接受
我试图在使用MPF.plot和Fig.Add_Axes绘制的多个图表中更改轴标题和字体大小,以将它们放在屏幕上。
我已经理解了此链接中给出的过程和示例如何更改MPLFINANCE标题的字体大小和字体类型以及在GitHub上讨论该方法,但它不适用于我的代码。我将“ returnfig = true”放置在任何地方都会导致错误。
这是我相关部分的代码段
fig = mpf.figure(figsize=(12,8),style='yahoo')
ax1 = fig.add_axes([0.05,0.70,0.3,0.25]) # ax = fig.add_axes([left,bottom,width,height])
ax2 = fig.add_axes([0.05,0.65,0.3,0.05])
ax3 = fig.add_axes([0.36,0.70,0.3,0.25])
ax4 = fig.add_axes([0.36,0.65,0.3,0.05])
ax5 = fig.add_axes([0.68,0.70,0.3,0.25])
ax6 = fig.add_axes([0.68,0.65,0.3,0.05])
ax7 = fig.add_axes([0.05,0.25,0.3,0.25])
ax8 = fig.add_axes([0.05,0.20,0.3,0.05])
ax9 = fig.add_axes([0.36,0.25,0.3,0.25])
ax10 = fig.add_axes([0.36,0.20,0.3,0.05])
ax11 = fig.add_axes([0.68,0.25,0.3,0.25])
ax12 = fig.add_axes([0.68,0.20,0.3,0.05])
mpf.plot(ausd,type='candle',ax=ax1,volume=ax2, mav=(9), show_nontrading=False, axtitle='M6A=F')
mpf.plot(gbpf,type='candle',ax=ax3,volume=ax4, mav=(9), show_nontrading=False, axtitle='M6B=F')
mpf.plot(cadf,type='candle',ax=ax5,volume=ax6, mav=(9), show_nontrading=False, axtitle='M6E=F')
mpf.plot(btcf,type='candle',ax=ax7,volume=ax8, mav=(9), show_nontrading=False, axtitle='M6C=F')
mpf.plot(gldf,type='candle',ax=ax9,volume=ax10, mav=(9), show_nontrading=False, axtitle='MBT=F')
mpf.plot(slvf,type='candle',ax=ax11,volume=ax12, mav=(9), show_nontrading=False, axtitle='MGC=F')
I am trying to change the axis titles and font size in multiple charts that are plotted using mpf.plot and fig.add_axes to place them on screen.
I have understood the process and examples given in this link How to change font size and font type in mplfinance title and on the github discussing the approach, but it will not work with my code. Anywhere I put "returnfig=True" it causes errors.
Here is my code snippet of the relevant section
fig = mpf.figure(figsize=(12,8),style='yahoo')
ax1 = fig.add_axes([0.05,0.70,0.3,0.25]) # ax = fig.add_axes([left,bottom,width,height])
ax2 = fig.add_axes([0.05,0.65,0.3,0.05])
ax3 = fig.add_axes([0.36,0.70,0.3,0.25])
ax4 = fig.add_axes([0.36,0.65,0.3,0.05])
ax5 = fig.add_axes([0.68,0.70,0.3,0.25])
ax6 = fig.add_axes([0.68,0.65,0.3,0.05])
ax7 = fig.add_axes([0.05,0.25,0.3,0.25])
ax8 = fig.add_axes([0.05,0.20,0.3,0.05])
ax9 = fig.add_axes([0.36,0.25,0.3,0.25])
ax10 = fig.add_axes([0.36,0.20,0.3,0.05])
ax11 = fig.add_axes([0.68,0.25,0.3,0.25])
ax12 = fig.add_axes([0.68,0.20,0.3,0.05])
mpf.plot(ausd,type='candle',ax=ax1,volume=ax2, mav=(9), show_nontrading=False, axtitle='M6A=F')
mpf.plot(gbpf,type='candle',ax=ax3,volume=ax4, mav=(9), show_nontrading=False, axtitle='M6B=F')
mpf.plot(cadf,type='candle',ax=ax5,volume=ax6, mav=(9), show_nontrading=False, axtitle='M6E=F')
mpf.plot(btcf,type='candle',ax=ax7,volume=ax8, mav=(9), show_nontrading=False, axtitle='M6C=F')
mpf.plot(gldf,type='candle',ax=ax9,volume=ax10, mav=(9), show_nontrading=False, axtitle='MBT=F')
mpf.plot(slvf,type='candle',ax=ax11,volume=ax12, mav=(9), show_nontrading=False, axtitle='MGC=F')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是 两种方式 可以访问MplFinance使用的图形和轴对象。 > 。
1。如果使用
returnfig = true
,则表示mpf.plot()
正在内部创建图形和轴对象,然后将它们返回给您以进行进一步的操作 you 最终调用mpf.show()
或图savefig()
完成图。2。,但是,如果您创建 您自己的 figue and轴对象 外部 to
mpf.plot()
,即使您使用mpf.figure()
来创建图对象,然后mpf.plot()
do 不是 自己的图形和轴对象,因此无法将它们返回给您!实际上,您已经拥有它们并拥有它们,因此没有意义来返回它们!这就是为什么当
mpf.plot()
>检测您已将轴传递到其中(因此处于“外部轴模式”),然后它将拒绝Kwargreturnfig
,因为在这种情况下,返回图形和轴是没有任何意义的你已经拥有了。The are two ways to gain access to the Figure and Axes objects that mplfinance uses. These two ways are documented here.
1. If you use
returnfig=True
it means thatmpf.plot()
is creating the Figure and Axes objects internally, and returning them to you for further manipulation before you eventually callmpf.show()
orfig.savefig()
to complete the plot.2. However, if you create your own Figure and Axes objects externally to
mpf.plot()
, even if you usempf.figure()
to create the Figure object, thenmpf.plot()
does not own the Figure and Axes objects, and so cannot return them to you!In fact, you already have them and own them so there is no point to returning them! This is why, when
mpf.plot()
detects that you have passed Axes into it (thus it is in "External Axes Mode") then it will reject the kwargreturnfig
because in that context it doesn't make any sense to return a Figure and Axes that you already have.我知道,如果您要在设置每个面板时访问
returnfig = true
,则需要。我的理解可能仍然缺乏。如果您设置了带有其他轴的子图,我认为您不需要returnfig = true
。在上一个问题中使用股票程序完成图表将导致以下代码。我引入了循环处理,缩短了长期格式,并降低了股票方向。I understand that
returnfig=True
is required if you want to access each of the panels when they are set up. My understanding may still be lacking. If you set up a subplot with additional axes, I don't think you needreturnfig=True
. Completing the graph with the ticker in the previous question would result in the following code. I introduced loop processing, shortened the long date format, and reduced the orientation of the ticker.