l would like to make a histogram with bars where each bar is set beside another bar for the same labem. From the post answered by @ImportanceOfBeingErnest l would like to make histogram with bars where we have a set of labels and two lists. For five labels for instance , l need to get 2 bars for each label (first for list1 and second for list2) Here is the original code.
from collections import Counter
import matplotlib.pyplot as plt
list1 = list("ABADEAABEDDA3EDBBBBBDG") # letters A, B, D, E, G
list2 = list("HAABAEEDCCFFFGEDABEEC") # all letters A-F, G,H
items1, counts1 = zip(*sorted(Counter(list1).items()))
items2, counts2 = zip(*sorted(Counter(list2).items()))
plt.bar(items1+items2, [5]*len(items1+items2), visible=False)
plt.bar(items1, counts1, label="list1")
plt.bar(items2, counts2, label="list2")
plt.legend()
plt.show()