2016-07-05 59 views
2

我有更多的數據框的列。 我可以使用ax = plt.gca()設置底部圖形,但是如何設置其他子圖的限制?如何使用Pandas數據框爲subplots設置ylim?

下面是我用於繪圖的代碼。

SomeDataFrame.plot(subplots=True, style=style, title='%s' % macID.upper(), grid=True, legend=True,) 
ax = plt.gca() 
ax.ylim=([lowlimit, highlimit]) 

plt.show() 

回答

1

SomeDataFrame.plot()返回它創建的子圖的列表。使用這個返回值可以訪問和操作它們。

mysubplots = SomeDataFrame.plot(subplots=True, style=style, title='%s' % macID.upper(), grid=True, legend=True,) 
firstplot = mysubplots[0] 
firstplot.set_ylim=([lowlimit, highlimit]) 
secondplot = mysubplots[1] 
secondplot.set_ylim=([lotherowlimit, otherhighlimit]) 

plt.show() 
+1

您是否測試過該功能是否有效?因爲我認爲你需要使用'set_ylim()'而不是'ylim()' – Bart

+0

在我的IPython shell和註釋字段之間的某處,我丟失了'set_'前綴。謝謝! –

相關問題