Fou*_*ier 5 python matplotlib pandas subplot
我才明白,matplotlib的tight_layout()不能被应用到所产生的地块大熊猫。
这是我正在运行的代码:
0 1 2 3 4
A 0.039895 0.960105 NaN NaN NaN
D 0.030418 0.969582 NaN NaN NaN
E 0.037345 0.962655 NaN NaN NaN
F 0.061522 0.938478 NaN NaN NaN
G 0.047163 0.952837 NaN NaN NaN
H 0.026423 0.000000 0.000000 0.973577 NaN
df.T.plot(kind='bar', subplots=True, width=0.7, legend=False,
layout=(2,4), sharex=True, sharey=True)
plt.tight_layout()
Run Code Online (Sandbox Code Playgroud)
我最终遇到以下错误:
AttributeError: 'NoneType' object has no attribute 'is_bbox'
Run Code Online (Sandbox Code Playgroud)
我也相信,这与github上发布的类似问题有关: DataFrame.hist()与matplotlib.pyplot.tight_layout()不相处#9351
因此,我正在寻找基于的解决方法subplots_adjust(*args, **kwargs)。最重要的是,我试图调整hspace参数。但是,调用pandasplot函数时不接受这些关键字参数。
有什么建议么?
tight_layout() 绝对适用于熊猫!没有 tight_layout()
df.T.plot(kind='bar', subplots=True, width=0.7, legend=False,
layout=(3, 2), sharex=True, sharey=True)
# plt.tight_layout()
Run Code Online (Sandbox Code Playgroud)
和 tight_layout()
df.T.plot(kind='bar', subplots=True, width=0.7, legend=False,
layout=(3, 2), sharex=True, sharey=True)
plt.tight_layout()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2729 次 |
| 最近记录: |