Title: | 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. |
Authors: | Mikko Marttila [aut, cre, cph] |
Maintainer: | Mikko Marttila <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2024-07-04 03:32:06 UTC |
Source: | https://github.com/mikmart/ggragged |
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.
facet_ragged_rows( rows, cols, ..., scales = "fixed", switch = NULL, labeller = "label_value" ) facet_ragged_cols( rows, cols, ..., scales = "fixed", switch = NULL, labeller = "label_value" )
facet_ragged_rows( rows, cols, ..., scales = "fixed", switch = NULL, labeller = "label_value" ) facet_ragged_cols( rows, cols, ..., scales = "fixed", switch = NULL, labeller = "label_value" )
rows , cols
|
A set of variables or expressions quoted by |
... |
Arguments reserved for future use. |
scales |
Should all panels share the same scales ( |
switch |
By default, facet labels are positioned to the top and right
of the panels. Use |
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 |
A Facet
that can be added to a ggplot
.
p <- ggplot(Indometh, aes(time, conc)) + geom_line() # Panels for each subject, with cohorts on separate rows p + facet_ragged_rows( vars(Cohort = 1 + Subject %in% 3:6), vars(Subject = as.character(Subject)), labeller = label_both ) # Independent y-axes between rows of cohorts p + facet_ragged_rows( vars(Cohort = 1 + Subject %in% 3:6), vars(Subject = as.character(Subject)), labeller = label_both, scales = "free_y" ) # Panels for each subject, with cohorts in separate columns p + facet_ragged_cols( vars(Subject = as.character(Subject)), vars(Cohort = 1 + Subject %in% 3:6), labeller = label_both ) # Independent y-axes for all subjects p + facet_ragged_cols( vars(Subject = as.character(Subject)), vars(Cohort = 1 + Subject %in% 3:6), labeller = label_both, scales = "free_y" )
p <- ggplot(Indometh, aes(time, conc)) + geom_line() # Panels for each subject, with cohorts on separate rows p + facet_ragged_rows( vars(Cohort = 1 + Subject %in% 3:6), vars(Subject = as.character(Subject)), labeller = label_both ) # Independent y-axes between rows of cohorts p + facet_ragged_rows( vars(Cohort = 1 + Subject %in% 3:6), vars(Subject = as.character(Subject)), labeller = label_both, scales = "free_y" ) # Panels for each subject, with cohorts in separate columns p + facet_ragged_cols( vars(Subject = as.character(Subject)), vars(Cohort = 1 + Subject %in% 3:6), labeller = label_both ) # Independent y-axes for all subjects p + facet_ragged_cols( vars(Subject = as.character(Subject)), vars(Cohort = 1 + Subject %in% 3:6), labeller = label_both, scales = "free_y" )