tallbar | R Documentation |
Stack multiple bar plots vertically (or horizontally).
tallbar(height, labels = names(height), groups = NULL, horiz = TRUE, ...)
height |
a list of |
labels, groups |
labels for each bar plot in |
horiz |
logical the direction of the bars |
... |
additional arguments passed to |
The default return of barplot2
plus additional elements
names
, labels
, and groups
giving the tick coordinates
and labels for each, useful for finer control over the axes; see examples.
x <- mtcars[, sapply(mtcars, function(x) length(unique(x)) < 5)]
y <- sapply(x, simplify = FALSE, function(x) t(table(x, mtcars$mpg > 25)))
x <- sapply(x, simplify = FALSE, function(x) t(table(x)))
tallbar(x, horiz = FALSE)
tallbar(x, las = 1)
tallbar(x, las = 1, groups = c('Group 2' = 2, 'Group 3' = 4))
bp <- tallbar(
y, horiz = TRUE, las = 1, axisnames = FALSE,
groups = c('Group 2' = 2, 'Group 3' = 4)
)
axis(2, bp$names, names(bp$names), las = 1, lwd = 0)
axis(2, bp$labels, names(bp$labels), las = 1, lwd = 0, font = 3)
axis(2, bp$groups, names(bp$groups), las = 1, lwd = 0, font = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.