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

标签 python pandas matplotlib subplot

我有不止这些数据框列。 我可以使用 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/

相关文章:

python - 在 AWS 上请求竞价实例时,如何附加现有 EBS 卷?

python - 将 pandas 数据框合并到新索引级别下

python - Pd 系列日期时间以格式转换为日期时间

Python Pandas 绘制标题名称传递字符串

python-3.x - 无法使seaborn fiddle 图水平[Python3.X]

python - 使用 matplotlib 重复 x 轴值

python - 带有查找表的 Pandas fillna

python - 与 MySQL 服务器 'remote_ip:3306' 失去连接,系统错误 : 2 No such file or directory

python - cpython _math.c 中的 ln2 const 值

python - 从 pickle 读取时,数据帧被解析为元组