I have data in a hashmap, and I want to create a histogram over this data using the keys as bins and the values as data.
My data:
N = {1: 12, 2: 15, 3: 8, 4: 4, 5: 1}
What I want plotted:
|
15| X
| X
| X
| X X
| X X
10| X X
| X X
| X X X
| X X X
| X X X
5| X X X
| X X X X
| X X X X
| X X X X
| X X X X X
|_________________________
1 2 3 4 5
I’ve tried to figure out how to do this with pyplot.hist(), but all overloads I can find take a list of values, not a hashmap. Do I really have to generate this list, just to let matplotlib count all the values again?
Just plot a bar graph. That’s all
histdoes.E.g.: