[英]How to perform subplot from existing axes with Matplotlib
I would like to add two (or more) axes ( ax1
and ax2
in my example), coming from different parts of my program, to a unique raw Figure
. 我想将来自程序不同部分的两个(或更多)轴(在我的示例中为ax1
和ax2
)添加到唯一的Raw Figure
。
Thus, in the first part of my program, I would do: 因此,在程序的第一部分中,我将执行以下操作:
fig1, ax1 = plt.subplots(1, 1)
ax1.scatter(...)
ax1.imshow()
...
and in a second part of this same program: 在同一程序的第二部分中:
fig2, ax2 = plt.subplots(1, 1)
ax2.plot(...)
...
I then would like to build a figure to incorporate these two axes ax1
and ax2
, with something like: 然后,我想构建一个图以将这两个轴ax1
和ax2
合并在一起,例如:
fig = plt.figure()
fig.add_my_subplots(ax1, ax2)
As it seems that an axis should be not linked/added to another Figure
in Matplotlib, I came up with a more simple solution: 似乎轴不应链接/添加到Matplotlib中的另一个Figure
,我想出了一个更简单的解决方案:
fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True)
do_my_stuff_with_first_axis(ax=ax1)
do_my_stuff_with_second_axis(ax=ax2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.