I have a long list of words, and I want to create a histogram of the frequency of each word in my list. I was able to do this 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()
However, it does not display cells by rank (i.e., by frequency, so the highest frequency is the first bit on the left, etc.), although when printing, countshe orders them for me Counter({'C': 4, 'A': 3, 'B': 2}), How can I achieve this?
source
share