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