使用 pandas 日期时间图时如何使一个轴占据多个子图?

How to make an axes occupy multiple subplots when using pandas datetime plot?

我想创建一个两行两列的(子)图,其中下行的图占据两个轴。

因为我在 pandas 日期时间(我认为)中使用了情节,所以我无法使用 this solution

fig, axes = plt.subplots(nrows=2, ncols=2)

df1.set_index('Date').plot(ax=axes[0,0])
df2.set_index('Date').plot(ax=axes[0,1])
df3.set_index('Date').plot(ax=axes ??? ) 

我需要如何分配轴(如果可能的话)才能得到这样的东西:

你可以这样做,例如:

df = pd.DataFrame( {'date':['2010-01-01','2010-01-02','2010-01-03'],'a1':[5,4,3],'a2':[6,2,9]})
df['date'] = pd.to_datetime(df['date'])
import matplotlib.pyplot as plt
fig = plt.figure()

ax1 = plt.subplot(221)
ax2 = plt.subplot(222)
ax3 = plt.subplot(212)

df.plot(x="date", y='a1',ax=ax1)
df.plot(x="date", y='a2',ax=ax2)
df.plot(x="date", y=['a1','a2'], ax=ax3)

plt.tight_layout()
plt.show()

为了完整起见,我发布了在 Whosebug 的帮助下生成的代码片段。两个传感器读数的日期时间不同步,所以我无法按照建议绘制。

fig = plt.figure()

ax1 = plt.subplot(221)
ax2 = plt.subplot(222)
ax3 = plt.subplot(212)

df1.plot(x='Date', y='series1',ax=ax1)
df2.plot(x='Date', y='series2',ax=ax2)
df1.plot(x='Date', y='series1',ax=ax3)
df2.plot(x='Date', y='series2',ax=ax3)

plt.tight_layout()
plt.show()