barlabel | R Documentation |
Add labels to a barplot
.
barlabel(
x,
labels = x,
at = barplot(x, plot = FALSE, horiz = horiz, beside = beside),
horiz = FALSE,
beside = FALSE,
hadj = 0,
vadj = 0,
position = c("middle", "top", "bottom"),
plot = TRUE,
...
)
x |
a vector or matrix of bar heights, typically the same object used
in |
labels |
labels for each bar segment |
at |
the position of the midpoint of each bar |
horiz |
logical; plot vertical (default) or horizontal bars |
hadj, vadj |
optional horizontal and vertical adjustments to the calculated coordinates |
position |
the position for labels relative to each bar segment, one of
|
plot |
logical; if |
... |
additional graphical parameters passed to |
A list containing the x- and y-coordinates at which labels
were drawn.
x <- table(mtcars$gear)
barplot(x)
barlabel(x, position = 'top', pos = 3L)
x <- table(mtcars$gear, mtcars$vs)
barplot(x)
barlabel(x, labels = sprintf('n = %s (%.1f%%)', x, x / colSums(x) * 109),
col = cm.colors(nrow(x)))
bp <- barplot(x, beside = TRUE)
barlabel(x, beside = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.