There are two special/critical aes()
mappings:
fill
(so the geom knows which column to map the fills to)
values
(which column you're mapping the filling for the squares with)
geom_waffle(mapping = NULL, data = NULL, n_rows = 10, make_proportional = FALSE, flip = FALSE, na.rm = NA, show.legend = NA, radius = grid::unit(0, "npc"), inherit.aes = TRUE, ...) GeomWaffle stat_waffle(mapping = NULL, data = NULL, geom = "waffle", n_rows = 10, make_proportional = FALSE, flip = FALSE, radius = grid::unit(0, "npc"), na.rm = NA, show.legend = NA, inherit.aes = TRUE, ...) StatWaffle
mapping | Set of aesthetic mappings created by |
---|---|
data | The data to be displayed in this layer. There are three options: If A A |
n_rows | how many rows should there be in the waffle chart? default is 10 |
make_proportional | compute proportions from the raw values? (i.e. each
value |
flip | If |
na.rm | If |
show.legend | logical. Should this layer be included in the legends?
|
radius | radius for round squares |
inherit.aes | If |
... | other arguments passed on to |
geom | geom to use (default is "waffle") |
An object of class GeomWaffle
(inherits from GeomRtile
, GeomRrect
, Geom
, ggproto
, gg
) of length 5.
data.frame( parts = factor(rep(month.abb[1:3], 3), levels=month.abb[1:3]), vals = c(10, 20, 30, 6, 14, 40, 30, 20, 10), fct = c(rep("Thing 1", 3), rep("Thing 2", 3), rep("Thing 3", 3)) ) -> xdf ggplot(xdf, aes(fill = parts, values = vals)) + geom_waffle() + facet_wrap(~fct)