一般に、軸は図に結合されています。その理由は、matplotlibは通常、バックグラウンドでいくつかの操作を実行して、図の中で見栄えを良くするためです。
some hacky ways around thisもありますが、this oneでもありますが、一般的な合意は、軸をコピーしようとしないでください。
一方、これは問題または制限である必要は全くありません。
あなたは常にプロットを行う関数を定義し、そのようないくつかの数字で、これを使用することができます。
import matplotlib.pyplot as plt
def plot1(ax, **kwargs):
x = range(5)
y = [5,4,5,1,2]
ax.plot(x,y, c=kwargs.get("c", "r"))
ax.set_xlim((0,5))
ax.set_title(kwargs.get("title", "Some title"))
# do some more specific stuff with your axes
#create a figure
fig, (ax1, ax2) = plt.subplots(1,2)
# add the same plot to it twice
plot1(ax1)
plot1(ax2, c="b", title="Some other title")
plt.savefig(__file__+".png")
plt.close("all")
# add the same plot to a different figure
fig, ax1 = plt.subplots(1,1)
plot1(ax1)
plt.show()