数据:
[OrderedDict([(u'X1', 1), (u'X2', 21), (u'X3', 47), (u'X4', 18)]),
OrderedDict([(u'X1', 25), (u'X2', 41), (u'X3', 16), (u'X4', 5)]),
OrderedDict([(u'X1', 5), (u'X2', 23), (u'X3', 54), (u'X4', 5)]),
OrderedDict([(u'X1', 0), (u'X2', 33), (u'X3', 43), (u'X4', 11)]),
OrderedDict([(u'X1', 2), (u'X2', 41), (u'X3', 30), (u'X4', 14)]),
OrderedDict([(u'X1', 16), (u'X2', 38), (u'X3', 22), (u'X4', 11)])]
来自dict的简单的histrogram:
import pylab as pl
import matplotlib.pyplot as plt
def histogram_plots(d,filename):
X = np.arange(len(d))
pl.bar(X, d.values(), align='center', width=0.5)
pl.xticks(X, d.keys())
ymax = max(d.values()) + 1
pl.ylim(0, ymax)
print d.keys()
plt.savefig('..\histograms\\'+filename) # plt.savefig('.\histograms\\'+'_'.join(d.keys()))