coord_brick {ggbrick} | R Documentation |
Cartesian coordinates with fixed "aspect ratio"
Description
A fixed scale coordinate system forces a specified ratio similar to
coord_fixed
. It holds the coordinates fixed at the right ratio
to ensure each brick is of the right dimensions.
Usage
coord_brick(
bricks_per_layer = 4,
ratio = NULL,
xlim = NULL,
ylim = NULL,
expand = TRUE,
clip = "on",
width = 0.9
)
coord_waffle(
bricks_per_layer = 4,
ratio = NULL,
xlim = NULL,
ylim = NULL,
expand = TRUE,
clip = "on",
width = 0.9
)
Arguments
bricks_per_layer |
Number of bricks per layer. Should match the |
ratio |
aspect ratio, expressed as |
xlim , ylim |
Limits for the x and y axes. |
expand |
If |
clip |
Should drawing be clipped to the extent of the plot panel? A
setting of |
width |
Column width. If using a different |
Value
ggplot object
Examples
# 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)