1
I have a graph and I want to plot the degree distribution. Example:
> library(igraph)
> g <- make_ring(10)
> degree(g)
[1] 2 2 2 2 2 2 2 2 2 2
> g2 <- sample_gnp(1000, 10/1000)
> degree_distribution(g2)
[1] 0.000 0.000 0.001 0.008 0.017 0.045 0.061 0.096 0.103 0.133 0.127 0.102 0.103 0.069 0.046 0.039 0.026 0.012 0.007
[20] 0.000 0.003 0.002
I want to plot the distribution of degrees with log scale, more or less like in the image below:
Great Carlos. But I have two questions. First:How to fix the Y axis between 0 and 1? That is, I would like q to stay: 0, 0.2, 0.4, 0.6, 0.8, 1 (since the probability varies between 0 and 1. Second: How do I have the line that accompanies the point (line power fit)?
– Fillipe
You can adjust the limits of the Y-axis with the option
ylim = c(1e-05, 1)
, you cannot put zero literally because you are taking the log out, and log(0) is infinite. As for the regression line, after adjusting the regression you want you can put withabline(modelo)
as suggested here: https://answall.com/a/6269/5010 but remember that this may not be the best way to estimate power law.– Carlos Cinelli
What is the best way to estimate power law?
– Fillipe