Description Usage Arguments Examples
View source: R/geom-mosaic-text.R
A mosaic plot with text or labels
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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. |
na.rm |
If |
divider |
Divider function. The default divider function is mosaic() which will use spines in alternating directions. The four options for partitioning:
|
offset |
Set the space between the first spine |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
as.label |
Show as a ggplot label (box with round corners) |
repel |
Use ggrepel wo labels don't overlap |
repel_params |
List of ggrepel parameters (e.g. list(point.padding = 0)) |
check_overlap |
If |
... |
other arguments passed on to |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | data(titanic)
ggplot(data = titanic) +
geom_mosaic(aes(x = product(Class), fill = Survived)) +
geom_mosaic_text(aes(x = product(Class), fill = Survived))
ggplot(data = titanic) +
geom_mosaic(aes(x = product(Class, Sex), fill = Survived),
divider = c("vspine", "hspine", "hspine")) +
geom_mosaic_text(aes(x = product(Class, Sex), fill = Survived),
divider = c("vspine", "hspine", "hspine"), size = 2)
ggplot(data = happy) +
geom_mosaic(aes(x = product(health), fill = happy), na.rm = TRUE, show.legend = FALSE) +
geom_mosaic_text(aes(x = product(happy, health)), na.rm = TRUE)
# avoid overlapping text
ggplot(data = happy) +
geom_mosaic(aes(x = product(health), fill = happy), na.rm = TRUE, show.legend = FALSE) +
geom_mosaic_text(aes(x = product(happy, health)), na.rm = TRUE, check_overlap = TRUE)
# or use ggrepel
ggplot(data = happy) +
geom_mosaic(aes(x = product(health), fill = happy), na.rm = TRUE, show.legend = FALSE) +
geom_mosaic_text(aes(x = product(happy, health)), na.rm = TRUE, repel = TRUE)
# and as a label
ggplot(data = happy) +
geom_mosaic(aes(x = product(health), fill = happy), na.rm = TRUE, show.legend = FALSE) +
geom_mosaic_text(aes(x = product(happy, health)), na.rm = TRUE, repel = TRUE, as.label=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.