scale2
scale2.Rmd
library(saferGraph)
Argument kind
scale2(n = 9, lim = c(2, 3.101), kind = "approx")
> [1] 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1
Argument safer_check
scale2(n = 9, lim = c(2, 3.101), safer_check = TRUE)
> [1] 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1
Strict number of main ticks
ymin = 2 ;
ymax = 3.101 ;
n = 5 ;
scale <- scale2(n = n, lim = c(ymin, ymax), kind = "strict") ;
scale ;
> [1] 2.00 2.28 2.55 2.83 3.10
par(yaxt = "n", yaxs = "i", las = 1) ;
plot(ymin:ymax, ymin:ymax, xlim = base::range(scale, ymin, ymax)[order(c(ymin, ymax))], ylim = base::range(scale, ymin, ymax)[order(c(ymin, ymax))], xlab = "DEFAULT SCALE", ylab = "NEW SCALE") ;
par(yaxt = "s") ;
axis(side = 2, at = scale)
strict “clean” number of main ticks
ymin = 2 ;
ymax = 3.101 ;
n = 5 ;
scale <- scale2(n = n, lim = c(ymin, ymax), kind = "strict.cl") ;
scale ;
> [1] 2.2 2.4 2.6 2.8 3.0
par(yaxt = "n", yaxs = "i", las = 1) ;
plot(ymin:ymax, ymin:ymax, xlim = base::range(scale, ymin, ymax)[order(c(ymin, ymax))], ylim = base::range(scale, ymin, ymax)[order(c(ymin, ymax))], xlab = "DEFAULT SCALE", ylab = "NEW SCALE") ;
par(yaxt = "s") ;
axis(side = 2, at = scale)
approximate number of main ticks, scale inversion
ymin = 3.101 ;
ymax = 2 ;
n = 5 ;
scale <- scale2(n = n, lim = c(ymin, ymax), kind = "approx") ;
scale ;
> [1] 3.0 2.8 2.6 2.4 2.2 2.0
par(yaxt = "n", yaxs = "i", las = 1) ;
plot(ymin:ymax, ymin:ymax, xlim = base::range(scale, ymin, ymax)[order(c(ymin, ymax))], ylim = base::range(scale, ymin, ymax)[order(c(ymin, ymax))], xlab = "DEFAULT SCALE", ylab = "NEW SCALE") ;
par(yaxt = "s") ;
axis(side = 2, at = scale)