python plot a dictionary

Solutions on MaxInterview for python plot a dictionary by the best coders in the world

showing results for - "python plot a dictionary"
Lia
18 Jul 2017
1# credit to the Stack Overflow user in the source link
2
3import matplotlib.pylab as plt
4
5lists = sorted(d.items()) # sorted by key, return a list of tuples
6
7x, y = zip(*lists) # unpack a list of pairs into two tuples
8
9plt.plot(x, y)
10plt.show()