customAxes: Generate Custom Plot Axes

Description Usage Arguments Examples

View source: R/utility_functions.R

Description

A function that, based on the x and y-axis boundaries, draws lines and labels for a specified set of axes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
customAxes(
  xl,
  yl,
  pos = c(1, 2),
  lnSz = 2,
  type = 2,
  label = NULL,
  lbPos = c(2.5, 2.5, 1, 2.5),
  lbSz = 1.5,
  inc = c(0, 0, 0, 0),
  axisLabel = NULL,
  axSz = 1.25,
  axPos = c(-1, -1, -1, -1),
  prec = 2
)

Arguments

xl

a vector with the lower and upper boundaries for the x-axis.

yl

a vector with the lower and upper boundaries for the y-axis.

pos

a vector indicating at which sides an axis should be drawn. The possible sides are:

  1. Bottom (codes = 'Bottom', 'B', 'b', '1', 1);

  2. Left (codes = 'Left', 'L', 'l', '2', 2);

  3. Top (codes = 'Top', 'T', 't', '3', 3);

  4. Right (codes = 'Right', 'R', 'r', '4', 4);

The number of elements in the vector tell the function how many axes to draw.

lnSz

the width of the axis lines.

type

the type of axis line to draw. 1 or 'extend' generates axis lines that extend past the boundaries, while 2 or 'truncated' truncates the axis lines at the boundaries.

label

the labels for the axes. Must match the length of variable pos else a warning is generated and no labels are added.

lbPos

the line positions of the labels for the axes.

lbSz

the font-size of the labels for the axes.

inc

the increments for the axis values. Must match the length of the variable pos else a warning is generated and no axis values are added. Set to 0 to suppress the adding of axis values.

axisLabel

An optional list matching in length to the variable pos, with each element consisting either of a list of the tick positions and their labels for a given axis, or NULL to suppress adding values to that axis.

axSz

the size of the font for the axis values.

axPos

the line position of the axes.

prec

the number of decimal values to report for the axis values.

Examples

1
2
3
4
5
6
7
8
9
layout( cbind( 1, 2 ) ) # 2 plotting panes
xl = c(0,1); yl = c(0,1); blankPlot(xl,yl) # Empty plot
customAxes( xl, yl, label = c( 'X', 'Y' ), lnSz = 2,
  inc = c(.25,.25), axSz = .75 )
xl = c(.5,2.5); yl = c(-1,1); blankPlot(xl,yl); abline( h = 0 )
customAxes( xl, yl, pos = c(1,4), label = c( 'Conditions', 'Values' ),
  lbSz = 1, lbPos = c(1,1),
  axisLabel = list( list( c(1,2), c('A','B') ), NULL ),
  inc = c(0,.5), axSz = .75 )

rettopnivek/utilityf documentation built on March 1, 2021, 7:05 p.m.