Plotting a python dict in order of key values

I have a python dictionary that looks like this:

In[1]: dict_concentration
Out[2] : {0: 0.19849878712984576,
5000: 0.093917341754771386,
10000: 0.075060643507712022,
20000: 0.06673074282575861,
30000: 0.057119318961966224,
50000: 0.046134834546203485,
100000: 0.032495766396631424,
200000: 0.018536317451599615,
500000: 0.0059499290585381479}

They keys are type int, the values are type float64. Unfortunately, when I try to plot this with lines, matplotlib connects the wrong points (plot attached). How can I make it connect lines in order of the key values?

Leave a Comment