2016-07-05 25 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_'前缀。谢谢! –

相关问题