If I had a dictionary of words and their frequency in a string, for example:
{'hello': 3, 'how': 4, 'yes': 10, 'you': 11, 'days': 10, 'are': 20, 'ago': 11}
How could I make a bar graph out of this using matplotlib? I found a previous question which had a seemingly good solution, but it didn't work for me (python: plot a bar using matplotlib using a dictionary)
When I run
plt.bar(range(len(d)), d.values(), align="center")
plt.xticks(range(len(d)), d.keys())
I get the error
TypeError: 'dict_keys' object does not support indexing
I don't really see where I'm indexing my dictionary. It might be because in the question from which I got the code the x-values were also numbers? I'm not sure.