Bar plotting of 99 keys dictionary (key = event, value = number_of_occurence)

Viewed 19

I'm beginning to learn matplotlib and I do not have much time to browse stackoverflow or the matplotlib doc. I think my issue is fairly simple but I cannot find a way to do it.

I have a dictionary with 99 keys representing events with the value being the number of occurence of that event.

dict = {'event_1' : '2' , 'event_2' : '14' , ... , 'event_99' : '5' }

I can plot it with this line :

plt.bar(dict.keys(), dict.values(), width)

enter image description here

But as you can see, it looks really bad.

What I would like to do is to color the bars based on events and get them as a legend to the side of the plot. Is this possible? Or do you think of a better way to represent the data?

Thanks

0 Answers
Related