Draws a hand-drawn Marimekko / Mekko chart: each column's width is one
category's (x) share of the total, and within a column the stacked segments
are a second category's (fill) shares, so every roughened tile's area is
the joint value. It is the value-weighted, segment-coloured cousin of
geom_sketch_mosaic() (and reuses its layout). Like geom_sketch_chord() it
is a constructor returning a list of ordinary sketch layers (tiles coloured by
fill, column labels, and optional width-percent labels), so it composes with
+ and any fill scale; pair it with theme_void() or theme_sketch().
geom_sketch_marimekko(
data,
x,
fill,
value,
...,
gap = 0.008,
fill_style = "solid",
alpha = 1,
colour = "grey30",
label = TRUE,
width_labels = TRUE,
label_size = 3.2,
label_colour = "grey20",
roughness = 1,
bowing = 1,
n_passes = 2L,
seed = NULL
)A list of ggplot2 layers.
A data frame.
Unquoted column name of the category that sets column widths.
Unquoted column name of the category stacked within each column.
Unquoted column name giving the weight. Default: every row counts as 1.
Other arguments passed on to the tile layer.
Gap between columns / segments, as a fraction of the unit square. Default 0.008 (Marimekko charts sit closer than mosaics).
Tile fill style; see geom_sketch_rect(). Default "solid".
Tile fill opacity. Default 1.
Tile outline colour. Default "grey30".
Draw column (x) labels under the chart? Default TRUE.
Draw each column's width percentage on top? Default
TRUE.
Label text controls.
Sketch parameters.
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,
StatSketchWaffle,
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_mosaic(),
geom_sketch_parallel(),
geom_sketch_qq(),
geom_sketch_quantile(),
geom_sketch_rose(),
geom_sketch_sunburst(),
geom_sketch_text(),
sketch_graph()
library(ggplot2)
sales <- data.frame(
region = rep(c("North", "South", "East"), each = 3),
product = rep(c("A", "B", "C"), times = 3),
revenue = c(40, 30, 10, 25, 25, 30, 15, 20, 5)
)
ggplot() +
geom_sketch_marimekko(sales, region, product, revenue, seed = 1L) +
scale_fill_sketch() +
theme_void()
Run the code above in your browser using DataLab