I have a long list of words, and I want to generate a histogram of the frequency of each word in my list. I was able to do that in the code below:
import csv
from collections import Counter
import numpy as np
word_list = ['A','A','B','B','A','C','C','C','C']
counts = Counter(merged)
labels, values = zip(*counts.items())
indexes = np.arange(len(labels))
plt.bar(indexes, values)
plt.show()
It doesn't, however, display the bins by rank (i.e. by frequency, so highest frequency is first bin on the left and so on), even though when I print counts
it orders them for me Counter({'C': 4, 'A': 3, 'B': 2})
. How could I achieve that?