I looked up the source code of the plot
function used by poweRlaw
and modified it:
lines_ <- function (x, y, ...)
{
.local <- function (x, cut = FALSE, draw = TRUE, ...)
{
xmin = x$getXmin()
cut_off = cut * xmin
x_values = x$dat
if (!cut)
x$setXmin(min(x_values))
y = dist_data_cdf(x, lower_tail = FALSE, xmax = max(x_values) + 1)
cut_off_seq = (x_values >= cut_off)
x_axs = x_values[cut_off_seq]
if (is(x, "discrete_distribution"))
x_axs = unique(x_axs)
x$setXmin(xmin)
x = x_axs
if (draw)
lines(x, y, ...)
invisible(data.frame(x = x, y = y))
}
.local(x, ...)
}
#----------------------------------------------------------
points_ <- function (x, y, ...)
{
.local <- function (x, cut = FALSE, draw = TRUE, ...)
{
xmin = x$getXmin()
cut_off = cut * xmin
x_values = x$dat
if (!cut)
x$setXmin(min(x_values))
y = dist_data_cdf(x, lower_tail = FALSE, xmax = max(x_values) + 1)
cut_off_seq = (x_values >= cut_off)
x_axs = x_values[cut_off_seq]
if (is(x, "discrete_distribution"))
x_axs = unique(x_axs)
x$setXmin(xmin)
x = x_axs
if (draw)
points(x, y, ...)
invisible(data.frame(x = x, y = y))
}
.local(x, ...)
}
The functions lines_
and points_
- draw the same graph as the
plot
function of the poweRlaw
package, but
- behave like the standard
lines
and points
functions in that they don't destroy the current graph.
First m_bs
and 'm_eq' separately:
> plot(m_bs, lwd=9, col="black")
> lines_(m_bs, lwd=5, col="green")

> plot(m_eq, lwd=9, col="black")
> lines_(m_eq, lwd=5, col="blue")

The x-ranges of these to graphs do not overlap. Hence xlim
has to be chosen appropriately to show both graphs in the same picture.
> plot( m_eq, lwd=8, col="black",
+ xlim=c(min(m_bs$dat,m_eq$dat),max(m_bs$dat,m_eq$dat)))
> lines_(m_eq, lwd=5, col="blue")
> points_(m_bs,lwd=8,col="black")
> lines_(m_bs, lwd=5, col="green")
>
