Question

I have several matplotlib Figure-objects that I want to combine to one large figure by placing them next to another.

  1. How to get them into one figure?
  2. How to make them the same height?

Note that I cannot change the way the individual figures are created. I can just use the resulting Figure objects.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top