prettybars: prettybars

Description Usage Arguments See Also Examples

View source: R/plot_special.R

Description

A barplot.

Usage

1
2
3
4
5
6
prettybars(x, y = names(x), emph = NULL, col.bar = grey(0.9),
  col.emph = "magenta1", col.y = "black", col.bg = "lightblue",
  cex.y = 0.5, FUN = mean, ..., fun.lab = "overall mean", digits = 2L,
  title = paste0("prettybar of ", m$x), sub = NULL, note = NULL,
  col.note = col.emph, subnote = "source: github.com/raredd/rawr",
  extra.margin = 0, pars = NULL)

Arguments

x

numeric vector; values of bar heights

y

rownames of bars (or extracted from a named vector)

emph

vector of bars to emphasize (must be in y)

col.bar

color of bars

col.emph

color of emphasis bars

col.y

color of y labels

col.bg

background color bars

cex.y

size of y labels

FUN

summary function to apply to x

...

additional arguments passed to FUN

fun.lab

text label for FUN

digits

numeric; digits after decimal after applying FUN

title

main title

sub

subtitle

note

optional note (top right)

col.note

color of note

subnote

optional subnote (bottom right)

extra.margin

extra left spacing for long y labels

pars

additional list of graphical parameters passed to par

See Also

prettybars2; bibar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
set.seed(1)
x <- setNames(round(runif(10), 2) * 100, LETTERS[1:10])
prettybars(x, FUN = NULL, fun.lab = NULL, cex.y = 1.2,
           bg = 'white', emph = 'F', digits = 2)

x <- setNames(mtcars$mpg, rownames(mtcars))
prettybars(x, emph = rownames(mtcars)[mtcars$hp < 100], extra.margin = 1,
           FUN = median, fun.lab = 'overall median mpg',
           title = 'motor trend cars', sub = '   (miles per gallon)',
           note = 'vehicles with less than 100 hp in bold')

prettybars(mtcars$mpg, y = rownames(mtcars), col.bg = 'snow',
           emph = rownames(mtcars)[grepl('Merc', rownames(mtcars))],
           extra.margin = 1, col.emph = 'cyan2',
           FUN = quantile, probs = c(.25, .5, .75), na.rm = TRUE,
           fun.lab = c('lower quartile','median','upper quartile'),
           note = "if you buy a Mercedes,\nget ready to pay for lots of gas",
           title = 'motor trend cars', sub = '   (miles per gallon)') 

raredd/plotr documentation built on Dec. 6, 2018, 6:59 a.m.