def plotbars(hists, bins, labels, filename):
plt.figure()
center = (bins[:-1] + bins[1:]) / 2
width = 0.7 * (bins[1] - bins[0])
for hist in hists:
plt.bar(center, hist, align='center', width=width)
plt.legend(labels)
plt.savefig(filename)
If I plot histograms like this plotbars([hist1, hist2], bins, ['hist1', 'hist2'], 'histo.png'), this plots the histograms on top of each other. I want to the bars of the histogram to be adjacent. The bin width for each are equal.


histsis?np.histogram()centerto the right in each iteration. For instance tocenter = [c + offset for c in center], whereoffset = bins[-1] - bins[0], in every iteration of yourfor-loop, or some such.