prettybars | R Documentation |
A barplot.
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
)
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 |
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 |
... |
additional arguments passed to |
fun.lab |
text label for |
digits |
numeric; digits after decimal after applying |
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 |
pars |
additional list of graphical parameters passed to
|
prettybars2
; bibar
; minbars
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)'
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.