在同一图上显示两个 DataFrame 时 pyplot 无法解释的行为使用 DatetimeIndex

问题描述

我在尝试在一个图上显示两个带有 DatetimeIndex 的 python-DataFrame 时遇到了无法解释的行为。 我有一个不同长度的 DataFrame x 和一个 DataFrame y,它们都包含一个列并具有 DatetimeIndex。根据我是先开始绘制 x 还是 y,曲线不会显示

图1(左)->显示正常

fig,ax = plt.subplots()
x.plot(ax = ax)
y.plot(ax = ax)

图 2(右)-> 不显示任何内容(2 个 x 轴的混合?-> 倾斜和不倾斜的 xticks)

fig,ax = plt.subplots()
y.plot(ax = ax)
x.plot(ax = ax)

Figure 2 ist not displaying any data

Pandas plot (matplotlib.pyplot) 似乎根据首先给出的 DataFrame 对 x 轴进行不同的处理。两个DataFrame中的索引相似(从频率来看,但这不应该起作用)

enter image description here

任何有关如何进一步调查此案的提示将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)