I have a list of values (integers) and I want to show on a graph how many times each value in it occurs. I have created a dictionary of values and corresponding frequencies from the list as after searching on here, that seemed best way to do it
I want to plot the data out on an xy loglog graph (with connecting lines) rather than use a bar plot.
The data points on the graph appear as expected when using
plot.loglog(degree_frequencies.keys(),degree_frequencies.values())
however, since the lines on the graph connect the first key-value "co-ordinate" to the second, second to third etc and being unordered, this creates a line that jumps about all over the place, rather than a line that goes from left to right.
Here is an example dataset - where the first "co-ordinate" pair has a higher x value than the second
degree_frequencies = {8: 1, 2: 6, 3: 1, 5: 2, 6: 2}
(if the dictionary was rearranged to {2: 6, 3: 1, 5: 2, 6: 2, 8: 1} the line would look fine)
Could anyone advise the best way to go about this? I am wondering if I need to treat the list differently in the first place or if there is in fact a way to plot data like this using matplotlib at all.
I'm a relatively inexperienced Python user, but I have spent some time trawling the internet and the documentation (which I'm finding heavy going) without finding an answer. Easy to understand/implement (in my circumstances) would probably be more helpful than elegant yet complex solutions (if poss).
Thanks