| Type: | Package |
| Title: | Waffle Style Chart with a Brick Layout in 'ggplot2' |
| Version: | 0.3.1 |
| Maintainer: | Daniel Oehm <danieloehm@gmail.com> |
| Description: | A new take on the bar chart. Similar to a waffle style chart but instead of squares the layout resembles a brick wall. |
| Depends: | R (≥ 3.5.0) |
| Imports: | ggplot2, dplyr, purrr, glue |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| NeedsCompilation: | no |
| Packaged: | 2025-09-15 00:36:12 UTC; danie |
| Author: | Daniel Oehm [aut, cre] |
| Repository: | CRAN |
| Date/Publication: | 2025-09-15 02:30:02 UTC |
GeomBrick
Description
GeomBrick
Usage
GeomBrick
Format
An object of class GeomBrick (inherits from GeomRect, Geom, ggproto, gg) of length 6.
GeomBrick
Description
GeomBrick
Usage
GeomBrick0
Format
An object of class GeomBrick0 (inherits from GeomBrick, GeomRect, Geom, ggproto, gg) of length 6.
GeomBrick
Description
GeomBrick
Usage
GeomWaffle
Format
An object of class GeomWaffle (inherits from GeomRect, Geom, ggproto, gg) of length 6.
GeomBrick
Description
GeomBrick
Usage
GeomWaffle0
Format
An object of class GeomWaffle0 (inherits from GeomWaffle, GeomRect, Geom, ggproto, gg) of length 6.
Brick row
Description
Brick row
Usage
brick_row(
layer,
bpl,
brick_height = 1,
brick_width = 2.5,
gap = 0.125,
width = 0.9,
.geom = "brick"
)
Arguments
layer |
Brick layer. |
bpl |
Number of bricks in the layer. |
brick_height |
Brick height. |
brick_width |
Brick width. |
gap |
Gap between the bricks. |
width |
Column width |
.geom |
Geom type for layering. Either 'brick' or 'brick_waffle' |
Build the wall
Description
Build the wall
Usage
build_wall(n_bricks, height, bpl, gap = NULL, width = 0.9)
Arguments
n_bricks |
Number of bricks |
height |
Height of the wall. |
bpl |
Bricks per layer |
gap |
The space between bricks. |
width |
Column_width |
Build the wall
Description
Build the wall
Usage
build_wall_waffle(n_bricks, height, bpl, gap = NULL, width = 0.9)
Arguments
n_bricks |
Number of bricks |
height |
Height of the wall. |
bpl |
Bricks per layer |
gap |
The space between bricks. |
width |
Column width. |
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)
half brick row
Description
half brick row
Usage
half_brick_row(
layer,
bpl,
brick_height = 1,
brick_width = 2.5,
gap = 0.125,
width = 0.9
)
Arguments
layer |
Brick layer. |
bpl |
Number of bricks in the layer. |
brick_height |
Brick height. |
brick_width |
Brick width. |
gap |
Gap between the bricks. |
width |
Column_width |
Fill
Description
Makes the vector for the fill aesthetic
Usage
make_new_fill(fill, n, val)
Arguments
fill |
The fill vector. |
n |
Vector representing the number of bricks for the fill level. |
val |
Vector of length the same as fill of with 1 o 0.5 for whole or half bricks. |
Robust random
Description
Ensures the half bricks are randomised in pairs to preserve the total
Usage
robust_random(x, val)
Arguments
x |
x. |
val |
Value. |
Robust round
Description
Robust round
Usage
robust_round(x, N)
Arguments
x |
Vector of values. |
N |
Value to preserve sum to. |
stat_brick
Description
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.
Usage
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,
...
)
Arguments
mapping |
Set of aesthetic mappings created by aes(). If specified and
|
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 |
Value
ggplot object
Aesthetics
geom_brick() understands the following aesthetics (required aesthetics are in bold):
x
y
alpha
colour
fill
group
linetype
linewidth
Examples
library(ggplot2)
library(dplyr)
mpg %>%
count(class, drv) %>%
ggplot() +
geom_brick(aes(class, n, fill = drv)) +
coord_brick()
stat_brick
Description
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.
Usage
stat_waffle(
mapping = NULL,
data = NULL,
geom = "rect",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
bricks_per_layer = 4,
type = "ordered",
gap = NULL,
width = 0.9,
...
)
geom_waffle(
mapping = NULL,
data = NULL,
stat = "waffle",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
bricks_per_layer = 4,
type = "ordered",
gap = NULL,
width = 0.9,
...
)
geom_waffle0(
mapping = NULL,
data = NULL,
stat = "waffle",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
bricks_per_layer = 4,
type = "ordered",
gap = 0,
width = 0.9,
...
)
Arguments
mapping |
Set of aesthetic mappings created by aes(). If specified and
|
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 |
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. |
width |
Column width. Default |
... |
Dots. |
stat |
The statistical transformation to use on the data for this
layer, either as a |
Value
ggplot object
Aesthetics
geom_waffle() understands the following aesthetics (required aesthetics are in bold):
x
y
alpha
colour
fill
group
linetype
linewidth
Examples
library(ggplot2)
library(dplyr)
mpg %>%
count(class, drv) %>%
ggplot() +
geom_waffle(aes(class, n, fill = drv)) +
coord_waffle()
Switch position for soft random
Description
Switch position for soft random
Usage
switch_pos(x, n)
Arguments
x |
Vector to switch values in. |
n |
Number to switch. |