# ensures that the ranges of axes are equal to the specified ratio by
library(ggplot2)
library(dplyr)
# create a base plot
plt <- mpg %>%
count(class, drv) %>%
ggplot() +
geom_brick(aes(class, n, fill = drv), bricks_per_layer = 6)
# view the base plot
plt
# View the base plot with fixed coords
# Ensure `bricks_per_layer` matches the geom
plt %>%
coord_brick(6)
# The same using `geom_waffle`
mpg %>%
count(class, drv) %>%
ggplot() +
geom_waffle(aes(class, n, fill = drv), bricks_per_layer = 6) +
coord_waffle(6)
Run the code above in your browser using DataLab