waffle_chart: Plot waffle charts

View source: R/waffle_charts.R

waffle_chartR Documentation

Plot waffle charts

Description

The function uses ggplot2 to create waffle charts from data.

Usage

waffle_chart(
  data,
  fill,
  value = "value",
  facet = NULL,
  composition = TRUE,
  max_value = NULL,
  digits = 3,
  fill_colors = NULL,
  fill_title = NULL,
  ncol = NULL,
  base_size = 12,
  line_size = LS(1),
  legend.position = "bottom"
)

Arguments

data

data frame to be plotted

fill

character specifying the column name which should be used as fill for the waffle plot.

value

character specifying the column name which contains values of the fill variable. Will be used to fill the waffle cells.

facet

character specifying the column name which should be used to facet_wrap waffle charts.

composition

logical indicating whether a compositional waffle (i.e. fill adds up to 100%) should be created. If FALSE, waffle cells will be scaled to max_value and missing cells filled with an "empty" category.

max_value

numerical giving the value to which waffle cells should be scaled to, if composition = FALSE.

digits

integer indicating the number of decimal places to be used in rounding of the waffle cells. The value 3 indicates percentages, while 4 permilles.

fill_colors

named character vector giving the colors for fill levels. See scale_fill_manual.

fill_title

character giving the title for the color legend.

ncol

number of columns to be used in facetting. See facet_wrap.

base_size

numeric giving the base size for the plot. See theme_void.

line_size

numeric value giving the size of lines between waffles cells.

legend.position

character specifying the position of the legend. See ggtheme.

Details

The waffle charts are read from left to right (like text) and from bottom upwards (like water glass). The cells indicate 1% of the maximum value (100

Value

Returns a ggplot2 waffle plot

Author(s)

Mikko Vihtakari with code ideas from hrbrmstr and Liam Gilbey

See Also

Other waffle: round_preserve_sum(), waffleize()


MikkoVihtakari/PlotSvalbard documentation built on July 12, 2022, 10:20 a.m.