def plot(self,direction,legend=True,**kwargs):
"""Plot all distributions; colors are set automatically to kwargs[cmap]."""
import pylab
pnormalize = pylab.normalize(vmin=1,vmax=len(self.distribution[direction]))
kwargs.setdefault('alpha',1.0)
kwargs.setdefault('linewidth',4)
fmt = kwargs.pop('fmt','-')
cmap = kwargs.pop('cmap',pylab.cm.jet)
count = 0
for target,(hist,edges) in self.distribution[direction].items():
count += 1
midpoints = 0.5*(edges[1:] + edges[:-1])
kwargs['color'] = cmap(pnormalize(count))
pylab.plot(midpoints,hist,fmt,label="%s" % target,**kwargs)
if legend:
pylab.legend(loc='best',
prop=pylab.matplotlib.font_manager.FontProperties(size=6))
评论列表
文章目录