matplotlib.pyplot不会忘记以前的绘图-如何刷新/刷新?
您如何matplotlib.pyplot“忘记”以前的地块 我正在尝试使用绘制多个时间 matplotlib.pyplot 代码如下: def plottest(): import numpy as np import matplotlib.pyplot as plt a=np.random.rand(10,) b=np.random.rand(10,) c=np.random.rand(10,) plt.plot(a,label='a') plt.plot(b,label='b') plt.plot(c,label='c') plt.legend(loc='upper left') plt.ylabel('mag') plt.xlabel('element)') plt.show() e=np.random.rand(10,) f=np.random.rand(10,) g=np.random.rand(10,) plt.plot(e,label='e') plt.plot(f,label='f') plt.plot(g,label='g') plt.legend(loc='upper left') plt.ylabel('mag') plt.xlabel('element)') plt.show() 不幸的是,无论我做什么,我都会得到相同的情节(实际上是从我之前运行并完成的其他代码中得到的)。 类似的代码以前为我工作。 我看了这些问题: 如何“清理板岩”? Matplotlib pyplot show()一旦关闭就无法正常工作 (python)matplotlib pyplot show()..是否阻止? 并尝试使用plt.show(),plt.clf()并plt.close无济于事。 有任何想法吗?