我尝试使用包powerlaw来绘制一些幂律拟合。它似乎适用于单条曲线。但我无法在同一张图上绘制多个图。 参考:这个包里有办法吗?【PS我是新手】
set.seed(1)
x1 <- ceiling(rlnorm(1000, 4))
x2 <- ceiling(rlnorm(1000, 2))
library(poweRlaw)
pl_d = pl_data$new(x1)
plot(pl_d)
#Now fit the powerlaw
m = displ$new(pl_d)
#Estimate the cut-off
#estimate_xmin(m)
aaa <- estimate_xmin(m)
aaa <- as.data.frame(aaa)
aaa <- aaa[2,1]
x_min <- min(table(x))
m$setXmin(aaa); m$mle()
#Plot the data and the PL line
#plot(m)
lines(m, col=2)
# next POWER LAW graph
#Plot the data
pl_d = pl_data$new(x2)
points(pl_d)
#Now fit the powerlaw
m = displ$new(pl_d)
#Estimate the cut-off
#estimate_xmin(m)
aaa <- estimate_xmin(m)
aaa <- as.data.frame(aaa)
aaa <- aaa[2,1]
x_min <- min(table(x))
m$setXmin(aaa); m$mle()
#Plot the data and the PL line
#points(m)
lines(m, col=3)