我想将我为一个图设置的子图轴数据分配给另一个图,如下所示。
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()
请注意,我在matplotlib: can I create AxesSubplot objects, then add them to a Figure instance?
中看到了答案我尝试使用fig2.axes.append(ax1)
,但这不起作用。我希望将ax1[0]
fig1
fig2
上设置的所有属性复制并显示在already installed here: Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg