Memo-migrated‎ > ‎

Save the subplot of matplotlib

posted Apr 18, 2019, 7:46 PM by Teng-Yok Lee   [ updated Jan 2, 2021, 8:39 PM ]

The solution is calling ax.get_tightbox() to get the entire region and converting per the figure's DPI. Based on the answer above, I wrote a short function to combine multiple axes:

def SaveAxes(fig, axes, fig_filepath):
    extents = [];
    for ax in axes:
    extent = Bbox.union(extents);
    plt.savefig(fig_filepath, bbox_inches = extent);