matplotlib - 如何将多个 matplotlib 图形合并为一个图形?

标签 matplotlib figure

我有几个 matplotlib 图形对象,我想通过将它们放在另一个旁边来组合成一个大图形。

  • 如何让它们合而为一?
  • 如何使它们高度相同?

  • 请注意,我无法更改创建单个图形的方式。我可以只使用生成的 Figure 对象。

    最佳答案

    似乎没有(可靠的 - 见底部)matplotlib 方法来做到这一点,所以人们坚持在图形输出上使用图像处理工具。为此,我正在使用 PNG 和 PIL。另一种可能性是使用 SVG,如下所示:http://neuroscience.telenczuk.pl/?p=331

    这是一个相关的问题:matplotlib: can I create AxesSubplot objects, then add them to a Figure instance?

    这是一种在 2012 年似乎有效的方法,由 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.



    我还没试过它是否仍然有效。

    关于matplotlib - 如何将多个 matplotlib 图形合并为一个图形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22521560/

    相关文章:

    python - 重用基础图而无需重新绘制

    python - 在绘图窗口中放置自定义图像 - 作为自定义数据标记或注释这些标记

    Python 索引错误 : index 1 is out of bounds for LDA

    python - 颜色条相对于地理轴的正确放置(cartopy)

    python - 如何更改绘图图形大小

    r - 使用RMarkdown的标题中的图形名称

    css - CSS flex元素在图像时不会增长或收缩

    python - pylab 和 pyplot 有什么区别?

    python - Matplotlib 归一化颜色条 (Python)

    matlab - 两个保存的图形,希望它们显示在 MATLAB 中的单个图形中