1

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.

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:

fig = plt.figure()
fig.add_my_subplots(ax1, ax2)
asked Nov 22, 2016 at 13:17
2
  • 1
    Something like this? Commented Nov 22, 2016 at 14:09
  • That's actually the way I ended up i.e. by means of a function. Commented Nov 22, 2016 at 14:18

1 Answer 1

3

As it seems that an axis should be not linked/added to another Figure in Matplotlib, I came up with a more simple solution:

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)
answered Nov 22, 2016 at 14:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.