I am using this function
It return one AxesSubplot:
I would like to save the plot that is ploted when show_plot=True
as a png without changing the function.
How should I proceed ?
Best regards !
CodePudding user response:
To get the whole figure, you could try:
ax.get_figure().savefig('fig_name.png')
If you have a figure with multiple subplots and you want to only extract one (ax
):
# Get the bounding box of the subplot and expand it to include the axis labels and ticks.
# You will have to play with the expanded parameters.
subplot_box = ax.get_window_extent().transformed(ax.get_figure().dpi_scale_trans.inverted()).expanded(1.2, 1.4)
ax.get_figure().savefig('subplot.png', bbox_inches=extent)