Add a line to a histogram to show the power law distribution in julia

78 views Asked by At

I have a value and plot a histogram like this (log-log scale): enter image description here The code for the histogram is as follows:

histogram(log.(degree), bins=50, yaxis = (:log10))
title!("Degree distribution (log-log scale)")

I want to add a line to the histogram to show it is a power law distribution. It will look like this: enter image description here

1

There are 1 answers

0
max xilian On

In Plots.jl you can just plot onto the previous plots (or more generally modify them) by adding a ! to the command, so if you want do plot a line (or any other data) on top of a histogram you can do something like:

using Plots
a = rand(100)
histogram(a)
plot!([0,1],[5,25])

The other part is how to get the fit of the power law distribution, but I assumed that your problem is more about how to plot those things. Distributions.jl might help with the distribution fitting.