将带有子图的熊猫图保存到一个文件

Fen*_*rir 4 python plot matplotlib pandas

我正在从以下数据框在pandas / jupyter笔记本中创建子图

METHOD1       A           B             C              D             E
METHOD2                                                                
high       1410          14           426          13781             1
low       74142         303        757024          95105            37
medium    99174         670        277013         640000           127
mono      46599         207        405108          16793           160

axs = ct.plot(kind='barh', subplots=True, legend=False, figsize=(24,16))
for ax in axs:
    ax.set_xscale('log')
Run Code Online (Sandbox Code Playgroud)

在Jupyter中,我得到一张包含4个子图的图像。我想将该图保存为一个png,但是

fig=axs.get_figure()
fig.savefig('plot.png')
Run Code Online (Sandbox Code Playgroud)

给出错误信息

AttributeError:“ numpy.ndarray”对象没有属性“ get_figure”

因为axs是子图的数组,所以我可以保存单个子图。

如何将所有子图保存到一张图像?

IMC*_*ins 6

axs[0].get_figure()

您正在尝试在numpy数组上调用matplotlib方法。