25  geom_w

25.1 geom_waffle

Package

#install.packages("remotes")
#remotes::install_github("hrbrmstr/waffle")

waffle (Rudis and Gandy 2023)

Description

Create waffle plots

Understandable aesthetics

required aesthetics

fill (so the geom knows which column to map the fills to)

values (which column you’re mapping the filling for the squares with)

See also

geom_bar, geom_col

Example

library(waffle)
worldbankdata |>
  filter(Region == "East Asia & Pacific" | Region == "Europe & Central Asia") |>
  select(Region, Income, Year) |>
  group_by(Region, Income) |>
  tally() |>
  ggplot(aes(fill=Income, values=n)) +
  geom_waffle(color = "white", size=1) +
  facet_wrap(~Region, ncol=1) +
  scale_x_discrete(expand=c(0,0)) +
  scale_y_discrete(expand=c(0,0)) +
  coord_equal()