'Plotting the Degree Distribution in Python iGraph

I want to plot the histogram of a degree distribution, but using the iGraph's plot() on the degree_distribution gives just that...a plot, but with no title, no labels, no nothing, like this: enter image description here

How can I add annotations to this plot?



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()

enter image description here

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