以下代码绘制到两个 PostScript (.ps) 文件,但第二个包含两行。
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
plt.subplot(111)
x = [1,10]
y = [30, 1000]
plt.loglog(x, y, basex=10, basey=10, ls="-")
plt.savefig("first.ps")
plt.subplot(111)
x = [10,100]
y = [10, 10000]
plt.loglog(x, y, basex=10, basey=10, ls="-")
plt.savefig("second.ps")
如何告诉 matplotlib 重新开始第二个情节?
最佳答案
有一个明确的数字命令,它应该为你做:
plt.clf()
如果你在同一个图中有多个子图
plt.cla()
清除当前坐标区。
https://stackoverflow.com/questions/741877/