Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting frequency distributions in python

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.

like image 479
Dopey Avatar asked May 07 '11 18:05

Dopey


1 Answers

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

like image 135
Paul Avatar answered Nov 14 '22 22:11

Paul