Title: | Ragged Grids for 'ggplot2' |
Version: | 0.2.0 |
Description: | Extend 'ggplot2' facets to panel layouts arranged in a grid with ragged edges. facet_ragged_rows() groups panels into rows that can vary in length, facet_ragged_cols() does the same but for columns. These can be useful, for example, to represent nested or partially crossed relationships between faceting variables. |
License: | MIT + file LICENSE |
URL: | https://github.com/mikmart/ggragged, https://mikmart.github.io/ggragged/ |
BugReports: | https://github.com/mikmart/ggragged/issues |
Depends: | ggplot2 |
Imports: | grid, gtable, rlang, vctrs |
Suggests: | covr, knitr, nlme, ragg, rmarkdown, roxygen2, testthat (≥ 3.0.0), vdiffr |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Collate: | 'facet_ragged.R' 'facet_ragged_rows.R' 'facet_ragged_cols.R' 'ggragged-package.R' 'grid.R' 'gtable.R' 'layout.R' |
NeedsCompilation: | no |
Packaged: | 2024-10-09 16:56:09 UTC; Mikko |
Author: | Mikko Marttila [aut, cre, cph] |
Maintainer: | Mikko Marttila <mikkmart@protonmail.com> |
Repository: | CRAN |
Date/Publication: | 2024-10-09 17:10:02 UTC |
ggragged: Ragged Grids for 'ggplot2'
Description
Extend 'ggplot2' facets to panel layouts arranged in a grid with ragged edges. facet_ragged_rows() groups panels into rows that can vary in length, facet_ragged_cols() does the same but for columns. These can be useful, for example, to represent nested or partially crossed relationships between faceting variables.
Author(s)
Maintainer: Mikko Marttila mikkmart@protonmail.com [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/mikmart/ggragged/issues
Lay out panels in a ragged grid
Description
These facets create layouts in-between ggplot2::facet_wrap()
and
ggplot2::facet_grid()
. Panels are arranged into groups stacked along the
defining dimension, but remain independent in the other dimension, allowing
for a grid with ragged edges. This can be useful, for example, to represent
nested or partially crossed relationships between faceting variables.
Usage
facet_ragged_rows(
rows,
cols,
...,
scales = "fixed",
switch = "none",
strips = "margins",
axes = "margins",
align = "start",
labeller = "label_value"
)
facet_ragged_cols(
rows,
cols,
...,
scales = "fixed",
switch = "none",
strips = "margins",
axes = "margins",
align = "start",
labeller = "label_value"
)
Arguments
rows , cols |
A set of variables or expressions quoted by |
... |
Arguments reserved for future use. |
scales |
Determines which panels share axis ranges. By default ( |
switch |
Determines how facet label strips are positioned. By default
( |
strips |
Determines which facet label strips are drawn. By default
( |
axes |
Determines which axes are drawn. By default ( |
align |
Determines how panels are positioned within groups. By default
( |
labeller |
A function that takes one data frame of labels and
returns a list or data frame of character vectors. Each input
column corresponds to one factor. Thus there will be more than
one with |
Value
A Facet
that can be added to a ggplot
.
Examples
p <- ggplot(mpg, aes(displ, cty)) + geom_point()
p + facet_ragged_rows(vars(drv), vars(cyl))
p + facet_ragged_cols(vars(cyl), vars(drv))
# Allow axes to vary between panels
p + facet_ragged_rows(vars(drv), vars(cyl), scales = "free_y")
p + facet_ragged_rows(vars(drv), vars(cyl), scales = "free")
# Change strip label positions
p + facet_ragged_rows(vars(drv), vars(cyl), switch = "y")
p + facet_ragged_rows(vars(drv), vars(cyl), switch = "both")
# Draw strips between panels
p + facet_ragged_rows(vars(drv), vars(cyl), strips = "all")
# Draw axes between panels
p + facet_ragged_rows(vars(drv), vars(cyl), axes = "all_x")
p + facet_ragged_rows(vars(drv), vars(cyl), axes = "all")
# Change panel alignment
p + facet_ragged_rows(vars(drv), vars(cyl), align = "end")