split_plot {tidyplots} | R Documentation |
Split plot into multiple subplots
Description
Split plot into multiple subplots
Usage
split_plot(
plot,
by,
ncol = NULL,
nrow = NULL,
byrow = NULL,
widths = 30,
heights = 25,
guides = "collect",
tag_level = NULL,
design = NULL,
unit = "mm"
)
Arguments
plot |
A |
by |
Variable that should be used for splitting. |
ncol , nrow |
The number of columns and rows per page. |
byrow |
Analogous to |
widths , heights |
The relative widths and heights of each column and row
in the grid. Will get repeated to match the dimensions of the grid. The
special value of |
guides |
A string specifying how guides should be treated in the layout.
|
tag_level |
A string ( |
design |
Specification of the location of areas in the layout. Can either
be specified as a text string or by concatenating calls to |
unit |
Unit of length. Defaults to |
Value
A tidyplot
object.
Examples
# Before splitting
energy %>%
dplyr::filter(year %in% c(2005, 2010, 2015, 2020)) %>%
tidyplot(y = power, color = energy_source) %>%
add_donut()
# Split by year
energy %>%
dplyr::filter(year %in% c(2005, 2010, 2015, 2020)) %>%
tidyplot(y = power, color = energy_source) %>%
add_donut() %>%
split_plot(by = year)
# Change dimensions of subplots
energy %>%
dplyr::filter(year %in% c(2005, 2010, 2015, 2020)) %>%
tidyplot(y = power, color = energy_source) %>%
add_donut() %>%
split_plot(by = year, widths = 15, heights = 15)
# Spread plots across multiple pages
energy %>%
dplyr::filter(year %in% c(2005, 2010, 2015, 2020)) %>%
tidyplot(y = power, color = energy_source) %>%
add_donut() %>%
split_plot(by = year, ncol = 2, nrow = 1)