GeomDice | R Documentation |
geom_dice()
creates a layer that displays dice-like symbols where each dot
represents a specific category. Dots are only shown when that categorical
variable is present in the data, allowing compact visual encoding.
geom_dice(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
ndots = NULL,
x_length = NULL,
y_length = NULL,
na.rm = FALSE,
show.legend = TRUE,
inherit.aes = TRUE,
...
)
mapping |
Set of aesthetic mappings created by
|
data |
A data frame. If |
stat |
The statistical transformation to use. |
position |
Position adjustment. |
ndots |
Integer (1–6): number of positions shown per dice. |
x_length |
x_length Numeric: used for aspect ratio. |
y_length |
y_length Numeric: used for aspect ratio. |
na.rm |
Remove missing values if |
show.legend |
Whether to include in legend. |
inherit.aes |
If |
... |
Additional arguments passed to |
A ggplot2
layer that draws dice with categorical dot encodings.
library(ggplot2)
df <- data.frame(
x = 1:3,
y = 1,
dots = c("A,B", "A,C,E", "F")
)
ggplot(df, aes(x, y, dots = dots)) +
geom_dice(ndots = 6, x_length = 3, y_length = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.