I have several matplotlib Figure-objects that I want to combine to one large figure by placing them next to another.
Note that I cannot change the way the individual figures are created. I can just use the resulting Figure objects.
It seems there is no (reliable - see bottom) matplotlib way of doing this, so one is stuck with using image processing tools on the figure-output. I'm using PNGs and PIL for that. Another possibility is using SVGs like here: http://neuroscience.telenczuk.pl/?p=331
That is a related question: matplotlib: can I create AxesSubplot objects, then add them to a Figure instance?
Here is a way that seemed to work in 2012, proposed by Joe Kington:
Axes deliberately aren't supposed to be shared between different figures now. As a workaround, you could do this fig2._axstack.add(fig2._make_key(a), a), but it's hackish and likely to change in the future. It seems to work properly, but it may break some things.
I haven't tried if it still works.
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