Plotting frequency distributions in python


Question

I have a graph stored in an adjacency list format. I randomly select a bunch of nodes and note the number of neighbors each of them have. I now want to plot the distribution, and the way I do it right now is by manually checking if the size of the neighbor set falls into a particular bucket (I set the bucket sizes manually and this checking process results in a bunch of very ugly if-then-else statements) and then increment the frequency accordingly. I then call matplotlib and plot the graph. This entire process seems really cumbersome and not pythonic at all. It's totally doable in Excel but I'm trying to make it as programmatic as possible.

I'm sure there's a better way to do this but I couldn't find anything related to frequency plotting. Any suggestions would be awesome.

1
6
5/7/2011 10:12:11 PM

Is matplotlib.pyplot.hist() what you are looking for?

15
5/7/2011 7:19:55 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon