我有这个简化的代码:
import numpy, pylab, random
data = [ random.gauss(1, 0.2) for x in range(1000) ]
fig = pylab.figure()
weights = numpy.ones_like(data)/float(len(data))
n, bins, patches =pylab.hist(data, bins=20, histtype='stepfilled',
weights=weights)
pylab.xlim(min(bins), max(bins))
pylab.ylim(0, 1)
p, = pylab.plot(bins)
pylab.savefig("test.png")
情节如下:
那条绿线是什么?我该如何删除它?
答案 0 :(得分:4)
那是因为你正在绘制y轴上的x轴的点(即绿线),你不需要plot()
:
import numpy, pylab, random
data = [ random.gauss(1, 0.2) for x in range(1000) ]
fig = pylab.figure()
weights = numpy.ones_like(data)/float(len(data))
n, bins, patches =pylab.hist(data, bins=20, histtype='bar',
weights=weights)
pylab.xlim(min(bins), max(bins))
pylab.ylim(0, 1)
pylab.show()