Pandas:为不同的子图设置不同的ylim和标题

4

假设我有这个数据框:

    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

我这样绘制(从这里):
axes = df.set_index('Type').plot.bar(subplots=True, legend=False)
plt.subplots_adjust(hspace=0.35)

enter image description here

我的问题是:如何为每个子图设置不同的ylim?以及如何修改Cat标题的字体大小?
1个回答

7
绘图方法会返回一个包含多个坐标轴的数组,存储在你的axes变量中。你可以访问每一个坐标轴并设置标题和纵轴范围。
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')

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接