The following code plots to two PostScript (.ps) files, but the second one contains both lines.
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")
How can I tell matplotlib to start afresh for the second plot?
plt.clf()vsplt.cla()? I have a general function that saves open figures (makes no assumptions, does not take the fig object) and I want inside of it to have a way to completely close everything after it saves so that when I start producing the next plot the next call to the save function doesn't save the same plot again by accident. Is it ok if I ALWAYS runplt.clf()vsplt.cla()in my save function no matter what? Does it always close everything?plt.show()did do that but in cluster that can lead to bugs.plt.close()? that worked for me and made sure I didn't accidentally save the same plot multiple times.