'Plotting the Degree Distribution in Python iGraph
Solution 1:[1]
Igraph is not meant to be a fully functional plotting library - the plot that it can generate for degree distributions is meant only for quock "eyeballing". Use a dedicated plotting library like matplotlib. The bins() method of the degree distribution object may be used to extract the bin counts of the histogram.
Solution 2:[2]
import igraph as ig
import matplotlib.pyplot as plt
# generate a 100-nodes random graph
g = ig.Graph.Barabasi(100, 2)
bins = 20
plt.hist(g.degree(), bins)
plt.show()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tamás |
| Solution 2 | Tommaso Mazza |


