stat_brick | R Documentation |
Creates a 'waffle' style chart with the aesthetic of a brick wall. Usage is
similar to geom_col
where you supply counts as the height of the bar. Each
whole brick represents 1 unit. Two half bricks equal one whole brick. Where
the count exceeds the number of brick layers, the number of bricks is scaled
to retain the brick wall aesthetic.
stat_brick(
mapping = NULL,
data = NULL,
geom = "rect",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
width = 0.9,
bricks_per_layer = 4,
type = "ordered",
gap = NULL,
...
)
geom_brick(
mapping = NULL,
data = NULL,
stat = "brick",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
bricks_per_layer = 4,
width = 0.9,
type = "ordered",
gap = NULL,
...
)
geom_brick0(
mapping = NULL,
data = NULL,
stat = "brick",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
bricks_per_layer = 4,
type = "ordered",
gap = 0,
width = 0.9,
...
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
Geom |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
width |
Column width. Default value is |
bricks_per_layer |
The number of bricks per layer. Default 4. |
type |
The type of fill ordering. one of 'ordered', 'random' or 'soft_random', Default 'ordered' |
gap |
The space between bricks. |
... |
Dots. |
stat |
The statistical transformation to use on the data for this
layer, either as a |
ggplot object
geom_brick()
understands the following aesthetics (required aesthetics are in bold):
x
y
alpha
colour
fill
group
linetype
linewidth
library(ggplot2)
library(dplyr)
mpg %>%
count(class, drv) %>%
ggplot() +
geom_brick(aes(class, n, fill = drv)) +
coord_brick()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.