funchir-plot: Convenience Functions for Plotting

funchir-plotR Documentation

Convenience Functions for Plotting

Description

tile.axes is used in for loops to generate axes in a multi-panel plot with shared x & y axes (within row and column).

xdev2in is the inverse of graphics::xinch; namely, it converts from plotting device units into inches.

Usage

   tile.axes(n, M, N, params = list(x = list(), y = list()),
             use.x = TRUE, use.y = TRUE)
   xdev2in(x = 1)
   ydev2in(y = 1)
   xydev2in(xy = 1)

Arguments

n

Integer. Cell in mfrow to which to apply the axes; fills by row, following base functionality.

M

Integer. Number of rows specified in mfrow.

N

Integer. Number of columns specified in mfrow.

params

A length-2 list. params$x is a list of parameters to be passed to the x-axis. params$y is a list of parameters to be passed to the y-axis.

use.x

logical. Should the x-axis be printed?

use.y

logical. Should the y-axis be printed?

x

numeric value to convert into inches (along the horizontal axis).

y

numeric value to convert into inches (along the vertical axis).

xy

numeric value to convert into inches (along both axes simultaneously).

Details

tile.axes provides a simple way to incorporate the plotting of axes into a loop which creates the plots in a matrix of plots (e.g., by using par(mfrow=c(2, 2))) when the axes are shared by all plots. x axes are only printed on the bottom row of plots, and y axes are only printed on the first column of plots–this saves potentially wasted / white space by eliminating redundant axes, yet can still be done in a loop.

Some graphics functions specify some arguments with units in inches (namely, graphics::arrows' length argument). graphics::xinch provides the inverse functionality enabling conversion from inches into plotting units; up to numerical accuracy, then, graphics::xinch(xdev2in(x)) == x.

See Also

xinch

Examples

  smpl <- rnorm(100)

  par(mfrow = c(2, 1), mar = c(0, 0, 0, 0), oma=c(5, 4, 4, 2) + .1)
  for (ii in 1:2){
    hist(smpl[sample(length(smpl), 100, rep = TRUE)], xaxt = "n", yaxt = "n")
    tile.axes(ii, 2, 1)
  }

MichaelChirico/funchir documentation built on April 26, 2022, 10:08 p.m.