Draws a hand-drawn waffle: a square grid (default 10x10 = 100 cells) where
each cell is coloured by category, so the number of cells of a colour reads as
that category's share of the whole. Map the category to fill; map a count to
weight if the data is already summarised (otherwise each row counts as one).
Cells are drawn with geom_sketch_tile(), so they take the usual roughened
outline and fill_style (including "watercolor"). Add ggplot2::coord_equal()
to keep the cells square. (cf. waffle::geom_waffle()).
Usage
StatSketchWaffle
geom_sketch_waffle(
mapping = NULL,
data = NULL,
stat = "sketch_waffle",
position = "identity",
...,
n_rows = 10L,
cells = 100L,
flip = FALSE,
width = 0.9,
height = 0.9,
colour = "grey35",
fill_style = "hachure",
roughness = 1,
bowing = 1,
n_passes = 2L,
seed = NULL,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)Arguments
- mapping
Aesthetic mappings created by
ggplot2::aes(). Requiresfill; optionallyweight(a per-row count).- data
Data to display.
- stat
Statistical transformation. Default
"sketch_waffle".- position
Position adjustment. Default
"identity".- ...
Other arguments passed on to the layer.
- n_rows
Number of rows in the grid. Default 10.
- cells
Total number of cells (the grid resolution). Default 100, i.e. a percentage waffle.
- flip
Fill columns top-down instead of bottom-up? Default
FALSE.- width, height
Cell size in grid units (gaps appear below 1). Default 0.9.
- colour
Outline colour for each cell. Default
"grey35".- fill_style
Cell fill style; see
geom_sketch_rect(). Default"hachure".- roughness, bowing, n_passes, seed
Sketch parameters.
- na.rm
Remove missing values silently? Default
FALSE.- show.legend
Logical; include in legend?
- inherit.aes
Override default aesthetics?
See also
Other sketch-geoms:
GeomSketchAbline,
GeomSketchArrow,
GeomSketchBoxplot,
GeomSketchBracket,
GeomSketchCallout,
GeomSketchChicklet,
GeomSketchCol,
GeomSketchContourFilled,
GeomSketchCurve,
GeomSketchDotplot,
GeomSketchDumbbell,
GeomSketchEdge,
GeomSketchEllipse,
GeomSketchEngrave,
GeomSketchGantt,
GeomSketchHex,
GeomSketchLine,
GeomSketchLinerange,
GeomSketchLollipop,
GeomSketchMarkCircle,
GeomSketchMarkHull,
GeomSketchPath,
GeomSketchPoint,
GeomSketchPolygon,
GeomSketchRect,
GeomSketchRibbon,
GeomSketchRug,
GeomSketchSegment,
GeomSketchSfPolygon,
GeomSketchSlope,
GeomSketchSmooth,
GeomSketchSpoke,
GeomSketchTextRepel,
GeomSketchViolin,
StatSketchBeeswarm,
StatSketchCalendar,
StatSketchDensityRidges,
StatSketchFunnel,
StatSketchPie,
StatSketchPyramid,
StatSketchRadar,
StatSketchStream,
StatSketchTreemap,
StatSketchWaterfall,
annotate_sketch(),
annotate_sketch_arrow(),
annotate_sketch_callout(),
annotate_sketch_highlight(),
geom_sketch_alluvial(),
geom_sketch_arc_diagram(),
geom_sketch_bin2d(),
geom_sketch_bump(),
geom_sketch_chord(),
geom_sketch_contour(),
geom_sketch_count(),
geom_sketch_dendrogram(),
geom_sketch_density(),
geom_sketch_density2d(),
geom_sketch_ecdf(),
geom_sketch_function(),
geom_sketch_histogram(),
geom_sketch_jitter(),
geom_sketch_marimekko(),
geom_sketch_mosaic(),
geom_sketch_parallel(),
geom_sketch_qq(),
geom_sketch_quantile(),
geom_sketch_rose(),
geom_sketch_sunburst(),
geom_sketch_text(),
sketch_graph()
Examples
library(ggplot2)
df <- data.frame(grp = c("Rent", "Food", "Travel", "Other"),
spend = c(45, 25, 20, 10))
ggplot(df, aes(fill = grp, weight = spend)) +
geom_sketch_waffle(seed = 1L) +
coord_equal() +
theme_sketch()
