通常我在这里总能得到我问题的答案,所以这里有一个新的答案。我正在做一些数据分析,在那里我导入不同的csv文件,设置索引,然后我试图绘制它。在
这是密码。请注意,我使用obdobje
和-obdobje
,因为索引来自不同的文件,但格式相同:
#to start plotting
fig, axes = plt.subplots(nrows=2, ncols=1)
#first dataframe
df1_D1[obdobje:].plot(ax=axes[0], linewidth=2, color='b', linestyle='solid')
#second dataframe
df2_D1[obdobje:].plot(ax=axes[0], linewidth=2, color='b',linestyle='dashed')
#third data frame
df_index[:-obdobje].plot(ax=axes[1])
plt.show()
以下是数据帧中导入的数据:
^{pr2}$所以,问题是,X轴是不共享的。他们关系密切,但不是共享的。有什么建议可以解决这个问题吗?我尝试使用sharex=True
,但Python每次都崩溃。在
提前谢谢各位。在
谨致问候,大卫
您可能需要将最终数据帧重新索引为所有数据帧的联合。
matplotlib
在启用sharex=True
时,将最后一个子图的x轴作为整个绘图的轴。这会让你相处得很好产生这个,
如您所见,轴现在已对齐。在
相关问题 更多 >
编程相关推荐