gpt4 book ai didi

python - 如何使用 Pandas 数据框为子图设置 ylim?

转载 作者:太空宇宙 更新时间:2023-11-04 05:27:45 24 4
gpt4 key购买 nike

我有不止这些数据框列。我可以使用 ax=plt.gca() 设置底部图形,但是如何设置其他子图的限制?

下面是我用于绘图的代码。

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

plt.show()

最佳答案

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()

关于python - 如何使用 Pandas 数据框为子图设置 ylim?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38204071/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com