I'm trying to make a large, multi-panel figure out of several smaller plots using matplotlib.
Usually, I would use plt.subplots
to create each individual subplot, however for the data I'm trying to plot at the moment, each panel figure is already made of a many individual subplots (~100), so taking the time to place each one of those subplots in the right place manually for each figure I want to combine into the main plot is too much.
I've been reading the matplotlib documentation, and it seems like I need to create multiple canvas
objects in a single window to get what I want. I found this issue on github (https://github.com/matplotlib/matplotlib/issues/6936) asking for a similar feature for a different use, and a similar MEP23 https://matplotlib.org/devel/MEP/MEP23.html. These both seem unresolved/not available.
Seems this may not be possible, or I'm just missing a way to do this. Either way, would be useful to know.
Example:
The code below generates an example of the type of figure I want to create and have several of these in a single plot.
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
x = np.linspace(0, 1, 100)
y = np.sin(2*np.pi*x)
fig, ax = plt.subplots(nrows=100)
for axis in ax:
axis.plot(x, y)
axis.set(yticks=[],
xticks=[])
sns.despine(ax=axis)
fig.text(0.5, 0.05, "x title", ha='center')
fig.text(0.05, 0.5, "y title", va='center', rotation='vertical')
fig.text(0.5, 0.9, "panel title", ha='center')
fig.subplots_adjust(hspace=0)
plt.show()