How to combine several matplotlib figures into one figure?

独自空忆成欢 提交于 2019-11-28 07:31:17

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/22521560/how-to-combine-several-matplotlib-figures-into-one-figure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!