widebars: Wide bar plots

View source: R/plot_special.R

widebarsR Documentation

Wide bar plots

Description

Create a series of barplots by grouping factor.

Usage

widebars(
  x,
  y,
  main = NULL,
  sub = NULL,
  foot = NULL,
  note = NULL,
  col = c("grey90", "grey30", "lightblue2", "dodgerblue2")
)

Arguments

x

vector of grouping values

y

numeric vector of data values

main, sub

main title and sub title for plot

foot, note

footnote (left-adjusted) and note (right) for plot

col

a vector of colors for elements of the form c(section background, text, negative bars, positive bars)

Examples

op <- par(
  oma = c(5,5,7,5), mar = c(5,0,3,.1), las = 1,
  fg = 'transparent', bg = 'grey98'
)
widebars(
  mtcars$gear, mtcars$mpg * sample(c(-1,1), 32, replace = TRUE),
  main = 'Motor Trend car road tests', sub = 'Miles per gallon by gear',
  foot = 'some footnote that is not important', note = 'blahblah'
)

par(
  oma = c(5,5,7,5), mar = c(5,0,3,.1), las = 1,
  fg = 'transparent', bg = 'grey98'
)
widebars(
  x <- rep(2004:2015, each = 4), rnorm(48),
  main = paste('Market value,', paste0(range(x), collapse = ' - ')),
  sub = 'Percent change, quarterly',
  foot = paste('Values current as of', format(Sys.time(), '%b %Y')),
  note = 'github.com/raredd'
)
par(op)


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