【发布时间】:2018-07-26 17:42:33
【问题描述】:
我想将 pandas 数据框的三列绘制为 2x2 子图布局:
rand=np.random.random((12,6))
df=pd.DataFrame(columns=['a','b','c','d','e','f'],data=rand)
ax=df.loc[:,'a':'c'].plot(subplots=True,layout=(2,2))
这给了我想要的结果(右下角有一个空图)。但是,如果我尝试使用
向所有这些子图添加另一列df.loc[:,'d':'f'].plot(subplots=True,ax=ax)
出现以下错误:
ValueError: The number of passed axes must be 3, the same as the output plot
有什么办法可以解决这个问题而不必重新排列子图的布局?
【问题讨论】:
标签: python pandas matplotlib