Add a waffle figure to the chart.

fig_waffle(
  g,
  ...,
  n = 500,
  rows = 10,
  size = c(1, 1),
  gap = 0.1,
  min_size = 15,
  sync = TRUE,
  data = NULL,
  inherit_asp = TRUE
)

Arguments

g

An object of class g2r or g2Proxy as returned by g2() or g2_proxy().

...

Options to pass to the figure, including asp(), and adjust(), active(), selected(), and config(), other key value pairs of are passed to style.

n

Number of squares to use.

rows

Number of rows.

size

Size of squares.

gap

Gap between squares.

min_size

Minimum size of squares.

sync

Whether to sync the axis data (align) with that used in other figures, set to FALSE to not sync or set to a character string to use as name of sync group.

data

A dataset (data.frame or tibble) to use to draw the figure.

inherit_asp

Whether to inherit the aspects paseed to g2() initialisation function.

Details

Requires the x and color aspects.

Examples

fruits <- data.frame(
  fruit = c("Apples", "Bananas", "Pears", "Oranges"),
  value = c(.45, .15, .35, .05) * 100
)

g2(fruits, asp(value, color = fruit)) %>%
  fig_waffle() %>%
  motif(padding = 50) %>%
  axis_hide()