Description Usage Arguments Format Examples
Bar Plot with Numbers at the Ends of the Bars. Options not mentioned here
work identical to geom_col
or geom_text
.
1 2 3 4 5 6 7 8 9 10 11 12 13 | geom_coltext(mapping = NULL, data = NULL, position = "dodge", ...,
stat = "identity", width = NULL, center_text = FALSE,
just_mirror = TRUE, just_mirror_cutoff = c(0.1, 0.9),
fontcolor = c(STAT.UP.Grey, STAT.UP.Lightgrey), parse = FALSE,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)
geom_bartext(mapping = NULL, data = NULL, position = "dodge", ...,
stat = "identity", width = NULL, center_text = FALSE,
just_mirror = TRUE, just_mirror_cutoff = c(0.1, 0.9),
fontcolor = c(STAT.UP.Grey, STAT.UP.Lightgrey), parse = FALSE,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)
GeomColtext
|
mapping |
|
data |
|
position |
|
... |
|
width |
|
center_text |
Logical value. If |
just_mirror |
Logical value. If |
just_mirror_cutoff |
Two numeric values between 0 and 1. The default of 0.9 for the second value means that if the text is supposed to appear outside the bars then for values larger (in absolute terms) than 90 flipped to appear inside. And vice versa for text inside bars and the first value of just_mirror_cutoff. This avoids text getting cutoff by the edge of the plot or text obscuring the bars for very small values. Set it to 0 or 1 to switch off. |
fontcolor |
Character vector of color specifications (names, hex-values, etc.). For text appearing inside the bars the geom will use the value "most unlike" the bar color. There are some limits to this and bugs to be found. |
parse |
|
na.rm |
|
show.legend |
|
inherit.aes |
Relevant aes are
The following
The following
|
An object of class GeomColtext
(inherits from GeomRect
, Geom
, ggproto
) of length 5.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | library(ggplot2)
X <- data.frame(x = 1:5, y = sample(1:100, 5))
ggplot(X, aes(x, y)) +
geom_coltext(injust = -1.5)
ggplot(X, aes(x, y)) +
geom_coltext(injust = 1.5)
ggplot(X, aes(x, y)) +
geom_coltext(injust = 1.5) +
coord_flip()
ggplot(X, aes(x, y, label = percentify(y))) +
geom_coltext(injust = -1.5) +
coord_flip()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.