您也可以,只需hold
关闭(doc)
import pylab as p
ax = p.gca()
ax.hold(False)
def simpledist(speclist,totalbugs,a):
data = [float(spec.pop)/float(totalbugs) for spec in speclist]
ax.hist(data)
ax.figure.savefig('/Home/s1215235/Documents/python/newfolder/' + str(a) + '.png')
当您添加新绘图时,它将为您清除轴。
如果你有一堆其他的艺术家,并且只想删除最近的一个,你可以使用remove
艺术家的实例函数。
import pylab as p
ax = p.gca()
# draw a bunch of stuff onto the axse
def simpledist(speclist,totalbugs,a):
data = [float(spec.pop)/float(totalbugs) for spec in speclist]
n, bins, h_art = ax.hist(data)
ax.figure.savefig('/Home/s1215235/Documents/python/newfolder/' + str(a) + '.png')
for ha in h_art:
h_a.remove()
# ax.figure.canvas.draw() # you might need this