无法使用pandas plot()函数组合条形图和折线图

2024-06-10 14:23:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用plot()将pandas数据帧的一列绘制为线图:

df.iloc[:,1].plot()

得到想要的结果:

enter image description here

现在我想使用

ax=df.iloc[:,3].plot(kind='bar',width=1)

结果是:

enter image description here

最后我想把两者结合起来

spy_price_data.iloc[:,1].plot(ax=ax)

不会产生任何情节。

为什么条形图的x记号与直线图的x记号如此不同?如何将两个图合并为一个图?


Tags: 数据pandasdfdataplot绘制barax