geom_bartext {ggpol} | R Documentation |
Repelling text for GeomBar.
Description
Repelling text for GeomBar.
Usage
geom_bartext(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
spacing = 0.003,
dir = "v",
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
parse |
If |
nudge_x |
Horizontal and vertical adjustment to nudge labels by. Useful for offsetting text from points, particularly on discrete scales. |
nudge_y |
Horizontal and vertical adjustment to nudge labels by. Useful for offsetting text from points, particularly on discrete scales. |
spacing |
Defaults to 0.003. Minimum spacing between labels in NPC units. |
dir |
Defaults to "v", i.e. vertical repel of overlapping groups of labels. Can alternatively be set to "h" for horizontal repel. |
check_overlap |
If |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Other arguments passed on to |
Examples
df <- data.frame(L = rep(LETTERS[1:2], each = 4),
l = rep(letters[1:4], 2),
val = c(96.5, 1, 2, 0.5, 48, 0.7, 0.3, 51))
ggplot(df, aes(x = L, y = val, fill = l)) +
geom_bar(stat = "identity") +
geom_bartext(aes(label = paste0(val, "%")), position = position_stack(vjust = 0.5)) +
ggtitle("GeomBartext")