目前我在 2x2 子图中绘制了 3 个图。它看起来像这样:
fig, axes = plt.subplots(nrows=2, ncols=2)
df1.plot('type_of_plot', ax=axes[0, 0]);
df2.plot('type_of_plot', ax=axes[0, 1]);
df3.plot('type_of_plot', ax=axes[1, 0]);
第 4 个子图是空的,我希望第 3 个子图占据整个最后一行。
我为第三个子图尝试了各种轴组合。像 axes[1]
、axes[1:]
、axes[1,:]
。但一切都会导致错误。
那么我怎样才能达到我想要的呢?
最佳答案
你可以这样做:
import matplotlib.pyplot as plt
fig=plt.figure()
a=fig.add_axes((0.05,0.05,0.4,0.4)) # number here are coordinate (left,bottom,width,height)
b=fig.add_axes((0.05,0.5,0.4,0.4))
c=fig.add_axes((0.5,0.05,0.4,0.85))
df1.plot('type_of_plot', ax=a);
df2.plot('type_of_plot', ax=b);
df3.plot('type_of_plot', ax=c);
plt.show()
我给你的rect
坐标可读性不是很好,但你可以很容易地调整它。
关于python - Pandas 情节,结合两个情节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38989178/