10

I want to assign the subplot axes data that I set for one figure to another as below.

import matplotlib.pyplot as plt

x = [1,2,3]
y = [1,2,3]

fig1, ax1 = plt.subplots(1,2,sharey=True)
ax1[0].plot(x,y)
ax1[0].set_xlabel("x")
ax1[0].set_ylabel("y")

fig2, ax2 = plt.subplots(4,4,sharex=True,sharey=True)

ax2[0,0] = ax1[0] # I was expecting this to set all the axis labels and plot data from ax1 



plt.show()

Note that I have seen the answer in matplotlib: can I create AxesSubplot objects, then add them to a Figure instance?

And I tried using the fig2.axes.append(ax1) but this doesnt work. I would like all the properties that were set on ax1[0] of fig1 to be copied over and displayed in fig2

Dipole
  • 1,840
  • 2
  • 24
  • 35
  • If you have seen those answers, why does your code not reflect this? Also make sure you have read *all* answers. If you have problems using another solution, share the code you have a problem with and clearly state what's wrong with it. Once the question is edited with a [mcve] of the attempt, don't forget to notify me, otherwise noone will notice the changes. – ImportanceOfBeingErnest Mar 03 '18 at 00:00

0 Answers0