是否使用matplotlib将同一绘图打印两次?

是否使用matplotlib将同一绘图打印两次?,matplotlib,plot,axes,subplot,Matplotlib,Plot,Axes,Subplot,我想用不同的轴绘制相同的mpl.pyplot.plot。我的代码如下所示: import matplotlib.pyplot as plt plt.subplot(211) plot1 = plt.plot(data) ax = plt.gca() plt.axis('equal') plt.grid() plt.xlabel('x') plt.ylabel('y') : much more stuff : plt.subplot(212) command_to_plot(last_plot

我想用不同的轴绘制相同的mpl.pyplot.plot。我的代码如下所示:

import matplotlib.pyplot as plt

plt.subplot(211)
plot1 = plt.plot(data)
ax = plt.gca()
plt.axis('equal')
plt.grid()
plt.xlabel('x')
plt.ylabel('y')
:
much more stuff
:

plt.subplot(212)
command_to_plot(last_plot)
ax.set_xlim(a, b)

但不幸的是,
command\u to\u plot
不存在。那么我该怎么做呢?

有什么东西阻止你自己定义
command\u to\u plot
并将所有绘图命令放在这个函数中吗?希望避免额外的复杂性和许多参数的传递,以及我的计算机应该只创建这个绘图一次的感觉。有什么东西阻止你自己定义
command\u to\u plot
并将所有绘图命令放在这个函数中?希望避免额外的复杂性和许多参数的传递,以及我的计算机应该只做一次创建这个绘图的工作的感觉。