pancakes: Plots two horizontal barplots back-to-back.

View source: R/pancakes.r

pancakesR Documentation

Plots two horizontal barplots back-to-back.

Description

This function plots two horizontal barplots back-to-back.

Usage

pancakes(
  x1,
  x2,
  sameScale = TRUE,
  xlim1 = NULL,
  xlim2 = NULL,
  tickLabelOffset = -0.05,
  xlab1 = "x1",
  xlab2 = "x2",
  xlab = NULL,
  xlabOffset = -0.12,
  tickSize = 0.01,
  labels = NULL,
  labelSide = "both",
  cexLab = 1,
  col1 = "gray70",
  col2 = "gray30",
  border1 = "black",
  border2 = "black",
  ...
)

Arguments

x1

Numeric, vector of values for the left-hand side of the plot. Values are plotted such that the first is represented by the lowest bar, the second the next-higher bar, and so on.

x2

Numeric, vector of values for the right-hand side of the plot, must be same length as x1.

sameScale

Logical, if TRUE (default) then use the same scale for both sides of the plot. If FALSE, then each side will have its own scale determined automatically unless xlim1 and/or xlim2 are non-NULL.

xlim1, xlim2

Two numeric values defining the x-axis limits for x1 and x2. Alternatively, if one or both are NULL (default), then the scale is determined automatically for either or both.

tickLabelOffset

Numeric, offset (in y-direction) of labels for x-axis tick marks.

xlab1, xlab2

Characters, names of each x-axis label. Note that by default these are used but if xlab is non-NULL, then it is used insetad.

xlab

Character, name of x-axis label.

xlabOffset

Numeric, offset (in y-direction) of x-axis label(s).

tickSize

Numeric, relative size of tick marks. Positive numbers grow them longer from the bottom of the x-axis, negative upward.

labels

Vector of same length as x1 or x2 with labels for bars. Can be numeric, character, integers, or anything else that prints. Default is NULL, in which case no labels are added.

labelSide

Character, either left, right, or both, indicating side on which bar labels are drawn.

cexLab

Either NA (default) or a numeric > 0. Size of label text.

col1, col2

Colors of bars.

border1, border2

Border colors of bars.

...

Arguments to pass to par or plot.

labelOffset

Numeric, offset (from border or plot region) for positioning of labels. Positive numbers move labels outward, negative inward.

Details

If you want to add elements (e.g., arrows) to the plot, then note that the x-axis is scaled fromm -1 to 1 with the two sets of bar plots abutting one another at x = 0. The y-axis is scaled from 0 to 1.

Value

None. Side-effect is to generate a plot.

See Also

barplot

Examples

x1 <- 10:1
x2 <- sample(11:20, 10)
labels <- LETTERS[10:1]
pancakes(x1, x2, labels = labels)
pancakes(x1, x2, sameScale = FALSE, labels=labels)

adamlilith/legendary documentation built on July 28, 2023, 8:13 p.m.