pandas :为不同的子图设置不同的ylim和标题 [英] Pandas: set different ylim and titles for different subplots

查看:44
本文介绍了 pandas :为不同的子图设置不同的ylim和标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有这个数据框:

 类型 Cat1 Cat2 Cat30 A 0.384000 0.393000 0.4580001 B 0.603337 0.381470 0.2997732 C 0.585797 0.452570 0.3176073 D 0.324715 0.765212 0.717755

我是这样绘制的(

我的问题:如何为每个子图设置不同的 ylim ?以及如何修改 Cat 标题的字体大小之类的内容?

解决方案

绘图方法返回 axes 变量中的坐标轴数组.您可以访问每个文件夹并设置标题和ylim.

axes = df.set_index('Type').plot.bar(subplots=True,legend=False)plt.subplots_adjust(hspace=0.35)axes [0] .set_ylim(0,1.1)axes [0] .set_title('hello')

Say I have this dataframe:

    Type       Cat1       Cat2       Cat3
0   A      0.384000   0.393000   0.458000
1   B      0.603337   0.381470   0.299773
2   C      0.585797   0.452570   0.317607
3   D      0.324715   0.765212   0.717755

That I plot like this (from here):

axes = df.set_index('Type').plot.bar(subplots=True, legend=False)
plt.subplots_adjust(hspace=0.35)

My problem: how can I set a different ylim for each subplot? And how can I modify things like the font size of the Cat titles?

解决方案

the plotting method returns an array of axes in your axes variable. You can access each one and set the title and ylim.

axes = df.set_index('Type').plot.bar(subplots=True, legend=False)
plt.subplots_adjust(hspace=0.35)
axes[0].set_ylim(0, 1.1)
axes[0].set_title('hello')

这篇关于 pandas :为不同的子图设置不同的ylim和标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆