I have often encountered and made long-tailed degree distributions/histograms from complex networks like the figures below. They make the heavy end of these tails, well, very heavy and crowded from many observations:
However, many publications I read have much cleaner degree distributions that don't have this clumpiness at the end of the distribution and the observations are more evenly-spaced.
!
How do you make a chart like this using NetworkX
and matplotlib
?
Use log binning (see also). Here is code to take a
Counter
object representing a histogram of degree values and log-bin the distribution to produce a sparser and smoother distribution.Generating a classic scale-free network in
NetworkX
and then plotting this:Produces the following plot showing the overlap between the "raw" distribution in blue and the "binned" distribution in red.
Thoughts on how to improve this approach or feedback if I've missed something obvious are welcome.