Python 子绘图未显示在绘图中-pyplots
我最近升级了我的pandas-python,我的pyplots程序过去一直在工作,但它不会以同样的方式处理子图。之前的脚本在一个图形上有三个图表,它们相互叠加。现在,当它运行时,只有第三个图表显示(在屏幕底部的1/3)。因此,我接近调试,但错过了一步。有人能给点建议吗?多谢各位 f是一个df:Python 子绘图未显示在绘图中-pyplots,python,pandas,matplotlib,Python,Pandas,Matplotlib,我最近升级了我的pandas-python,我的pyplots程序过去一直在工作,但它不会以同样的方式处理子图。之前的脚本在一个图形上有三个图表,它们相互叠加。现在,当它运行时,只有第三个图表显示(在屏幕底部的1/3)。因此,我接近调试,但错过了一步。有人能给点建议吗?多谢各位 f是一个df: Date Open High Low Close Volume Adj_Close 2011-01-03 15.82 16.200001 15.78 15.8
Date Open High Low Close Volume Adj_Close
2011-01-03 15.82 16.200001 15.78 15.8 41760200 15.014473
2011-01-04 16.450001 16.59 16.209999 16.52 75576400 15.698677
2011-01-05 16.34 16.59 16.110001 16.559999 48278700 15.736688
2011-01-06 16.719999 16.719999 16.23 16.360001 37700800 15.546632
2011-01-07 16.450001 16.469999 16.1 16.42 36302500 15.603649
代码:
再次感谢您我相信这是因为您没有为前两个绘图指定轴。试着这样做:
fig, (ax1,ax2,ax3) = plt.subplots(3,1)
f.plot(y= ['Adj_Close','Open'], title= ticker + " Close & Open", ax=ax1)
f.plot(y= ['High', 'Low'], title='High and Low', ax=ax2)
ax3.bar(f.index, f['Volume'], width = 1)
plt.tight_layout()
因此,每个绘图都明确指定给一个特定的轴对象。您可以使用plt.subplot返回的“figure”对象来设置大小,如果这很重要:fig.set\u size\u inches
fig, (ax1,ax2,ax3) = plt.subplots(3,1)
f.plot(y= ['Adj_Close','Open'], title= ticker + " Close & Open", ax=ax1)
f.plot(y= ['High', 'Low'], title='High and Low', ax=ax2)
ax3.bar(f.index, f['Volume'], width = 1)
plt.tight_layout()