Although the use of pie charts is very common, there have been numerous cognitive studies that suggest people actually have a hard time discerning how the area of the various slices relates to actual percentages. If you feel really tempted to use a pie chart, ask yourself whether or not the data would be better displayed in a table.
Waffleplots
So-called waffle plots offer an alternative to pie charts. Waffle plots are square or rectangular representations of proportion data. Here’s an example of some waffle plots created with Bob Rudis’ waffle package. The data are summaries of the sources, forms, and fates of greenhouse gas emissions.from the Intergovernmental Panel on Climate Change (IPCC).
library(hrbrthemes)
library(waffle)
## data frame of GHG data
ghg <- tibble(
parts = as.factor(c("CO2 - fossil fuels", "CO2 - land use", "CO2 - chemicals",
"Methane", "Nitrous oxide", "Flourinated gases",
"Electricity", "Food & land use", "Transportation",
"Industry", "Buildings", "Other energy",
"Increase in atmosphere", "Land-based sink",
"Ocean-based sink")),
values = c(62, 11, 3, 16, 6, 2, 25, 24, 14, 21, 6, 10, 45, 32, 23),
category = c(rep("Greenhouse gas emissions", 6),
rep("Greenhouse gas sources", 6),
rep("Fate of CO2 emissions", 3))
)
## Greenhouse gas emissions
ghg_1 <- filter(ghg, category == "Greenhouse gas emissions")
ghg_p1 <- ggplot(ghg_1,
aes(fill=parts, values=values)) +
geom_waffle(color = "white", size = 0.5, n_rows = 10) +
scale_x_discrete(expand=c(0,0)) +
scale_y_discrete(expand=c(0,0)) +
ggthemes::scale_fill_tableau(name=NULL,
palette = "Miller Stone",
type = "regular",
direction = 1,
breaks = ghg_1$parts) +
coord_equal() +
labs(
title = unique(ghg_1$category)
) +
theme_ipsum_rc(grid="") +
theme_enhance_waffle()
## Greenhouse gas sources
ghg_2 <- filter(ghg, category == "Greenhouse gas sources")
ghg_p2 <- ggplot(ghg_2,
aes(fill=parts, values=values)) +
geom_waffle(color = "white", size = 0.5, n_rows = 10) +
scale_x_discrete(expand=c(0,0)) +
scale_y_discrete(expand=c(0,0)) +
ggthemes::scale_fill_tableau(name=NULL,
palette = "Miller Stone",
type = "regular",
direction = 1,
breaks = ghg_2$parts) +
coord_equal() +
labs(
title = unique(ghg_2$category)
) +
theme_ipsum_rc(grid="") +
theme_enhance_waffle()
## Fate of CO2 emissions
ghg_3 <- filter(ghg, category == "Fate of CO2 emissions")
ghg_p3 <- ggplot(ghg_3,
aes(fill=parts, values=values)) +
geom_waffle(color = "white", size = 0.5, n_rows = 10) +
scale_x_discrete(expand=c(0,0)) +
scale_y_discrete(expand=c(0,0)) +
ggthemes::scale_fill_tableau(name = NULL,
palette = "Color Blind",
type = "regular",
direction = -1,
breaks = ghg_3$parts) +
coord_equal() +
labs(
title = unique(ghg_3$category)
) +
theme_ipsum_rc(grid="") +
theme_enhance_waffle()
## stick the plots together
iron(ghg_p1, ghg_p2, ghg_p3)