Reputation: 528
Using matplotib
I have several Figure
objects being returned from different plotting functions. The figures are expensive to produce with specific formatting for each one, [fig1, fig2, fig3, fig4]
.
I need to arrange these in different layouts. For examples a column containing fig1, fig3, fig4; a row containing all figures; a 2x2 grid of all figures, and so on. I looked at pyplot.subplots
but this returns an array of axes that cannot be set.
How do I combine these separate figure objects into multiple subplots?
My actual case has 20+ expensive figures that need to be arranged in several different layouts so I really cannot re-plot the figures for every layout combination.
Upvotes: 3
Views: 2095
Reputation: 11
did you mean somethink like THIS:
import matplotlib.pyplot as plt
fig, axs = plt.subplots(ncols=3, nrows=3)
gs = axs[1, 2].get_gridspec()
# remove the underlying axes
for ax in axs[1:, -1]:
ax.remove()
axbig = fig.add_subplot(gs[1:, -1])
axbig.annotate('Big Axes \nGridSpec[1:, -1]', (0.1, 0.5),
xycoords='axes fraction', va='center')
fig.tight_layout()
plt.show()
Upvotes: 1