View source: R/ggplot-geom-subrect.R
| geom_subrect | R Documentation |
These geoms subdivide rectangles with shared borders into a grid. Both geoms achieve the same result but differ in how the rectangles are parameterized:
geom_subrect(): Defines rectangles using their four corners (xmin,
xmax, ymin, ymax).
geom_subtile(): Defines rectangles using the center (x, y) and
dimensions (width, height).
geom_subrect(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
byrow = FALSE,
nrow = NULL,
ncol = NULL,
lineend = "butt",
linejoin = "mitre",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
direction = deprecated()
)
geom_subtile(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
byrow = TRUE,
nrow = NULL,
ncol = NULL,
lineend = "butt",
linejoin = "mitre",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
direction = deprecated()
)
geom_subrect() understands the following aesthetics. Required aesthetics are displayed in bold and defaults are displayed for optional aesthetics:
| • | x or width or xmin or xmax | |
| • | y or height or ymin or ymax | |
| • | alpha | → NA |
| • | colour | → via theme() |
| • | fill | → via theme() |
| • | group | → inferred |
| • | linetype | → via theme() |
| • | linewidth | → via theme() |
geom_subtile() understands the following aesthetics. Required aesthetics are displayed in bold and defaults are displayed for optional aesthetics:
| • | x | |
| • | y | |
| • | alpha | → NA |
| • | colour | → via theme() |
| • | fill | → via theme() |
| • | group | → inferred |
| • | height | → 1 |
| • | linetype | → via theme() |
| • | linewidth | → via theme() |
| • | width | → 1 |
Learn more about setting these aesthetics in vignette("ggplot2-specs").
# arranges by row
ggplot(data.frame(value = letters[seq_len(5)])) +
geom_subtile(aes(x = 1, y = 1, fill = value), byrow = TRUE)
# arranges by column
ggplot(data.frame(value = letters[seq_len(9)])) +
geom_subtile(aes(x = 1, y = 1, fill = value))
# one-row
ggplot(data.frame(value = letters[seq_len(4)])) +
geom_subtile(aes(x = 1, y = 1, fill = value), nrow = 1)
# one-column
ggplot(data.frame(value = letters[seq_len(4)])) +
geom_subtile(aes(x = 1, y = 1, fill = value), ncol = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.