bibar: Bi-barplot

View source: R/plot2.R

bibarR Documentation

Bi-barplot

Description

Plot a bi-directional bar plot with optional side bars.

Usage

bibar(
  x,
  left = NULL,
  right = NULL,
  sleft = NULL,
  sright = NULL,
  col = NULL,
  xlim = NULL,
  ylim = NULL,
  axes = TRUE
)

Arguments

x

a table- or matrix-like object

left, right

a vector of integers giving the column indices of x to draw on the left and right sides from the origin to either side

sleft, sright

as above but bars drawn from the left or right side to the origin

col

a vector of colors for each column

xlim, ylim

x- and y-axis limits

axes

logical; if TRUE, the figure is framed and the x- and y-axes are drawn

See Also

prettybars2

Examples

set.seed(1)
x <- datasets::ability.cov$cov
x <- x[sample(seq.int(nrow(x)), 20, TRUE), ]

bibar(x, left = 1:3, right = 4:6, xlim = c(-250, 250))

palette(c('grey90', 'cornflowerblue', 'blue', 'tomato', 'tomato3'))
bibar(x, left = 2:3, right = 4:5, sleft = 1, sright = 6)
legend('topleft', inset = c(0, -0.2), xpd = NA, fill = 3:2,
       legend = colnames(x)[3:2], horiz = TRUE, bty = 'n')
legend('topright', inset = c(0, -0.2), xpd = NA, fill = 4:5,
       legend = colnames(x)[4:5], horiz = TRUE, bty = 'n')
palette('default')


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.