plot_loglog: Log-log scatterplot

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Scatterplot with logarithmic axes and gridlines.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
plot_loglog(
  x,
  y,
  xlim = c(1, 1000),
  ylim = c(1, 1000),
  xlog = TRUE,
  ylog = TRUE,
  xbase = 10,
  ybase = 10,
  grdcol = "#00000020",
  ...
)

Arguments

x, y

vectors of x- and y-axis values

xlim, ylim

numeric vectors of length 2, giving x,y ranges on linear scale

xlog, ylog

logical, should x,y axes be log-transformed? In case the linear scale is chosen, no gridlines are drawn.

xbase, ybase

numeric, base of the logarithm of the respective axes. Ignored if linear axis is specified.

grdcol

single value, color to be used for logarithmic gridlines

...

further arguments passed to other methods

Details

Emulates classic log-log graph paper. X and Y axes controlled independently. Points may be added post-hoc.

Value

A plot object

Author(s)

Petr Kiel

See Also

Lightly modified from http://www.petrkeil.com/?p=2701

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# compare linear vs logarithmic axes
par(mfrow=c(1,2))
x <- seq(1, 1000, by=10)
plot(x, x, ylim=c(0,4000), las=1, bty='l')
points(x, x^0.8, col='blue')
points(x, x^1.2, col='red')
plot_loglog(x=log10(x), y=log10(x), xlab='X axis', ylab='Y axis',
            ylim=c(1, 10000), pch=16, col='#00000030')
points(log10(x), 0.8*log10(x), pch=16, col='#0000FF30')
points(log10(x), 1.2*log10(x), pch=16, col='#FF000030')

# one axis log, one axis linear
x <- 1:1000
y <- dlnorm(x, meanlog=4)
yl <- c(0,0.012)
plot(x, y, ylim=yl, ylab='Pr density', bty='l', las=1)
plot_loglog(log10(x), y, ylog=FALSE, ylim=yl, xlim=c(0.1,1000),
     ylab='Pr den', pch=16, col='#00000030')
par(mfrow=c(1,1))

phytomosaic/ecole documentation built on Jan. 2, 2022, 11:24 p.m.