I am creating subplots in pandas/jupyter notebook from the following dataframe
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')
In Jupyter I get one image with 4 subplots. I want to save that plot to one png, but
fig=axs.get_figure()
fig.savefig('plot.png')
gives an error message
AttributeError: 'numpy.ndarray' object has no attribute 'get_figure'
because axs is an array of the subplots I can save the individual subplots.
How can I save all the subplots to one image?
When you use Pandas to plot graphs, the pd. plot() function returns the Matplotlib axis object which can be used to make changes to the graph and to save it in later cells in the Jupyter notebook.
MatPlotLib with Python Create a new figure (fig2) or activate an existing figure using figure() method. Plot the Second line using plot() method. Initialize a variable, filename, to make a pdf file. Create a user-defind function, save_multi_image, and call it to save all the open matplotlib figures in one file at once.
Matplotlib plots can be saved as image files using the plt. savefig() function.
Do axs[0].get_figure()
.
You are trying to call a matplotlib method on a numpy array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With