Split plot into multiple subplots
Usage
split_plot(plot, by=NULL, rows=NULL, cols=NULL, ncol=NULL, nrow=NULL, axes="all", scales=NULL,...)Arguments
- plot
A
tidyplotgenerated with the functiontidyplot().- by
One variable that should be used for splitting.
- rows, cols
Two variables that should be used for splitting, representing rows and columns, respectively.
- ncol, nrow
The number of columns and rows per page. Only takes effect when using
byto split by a single variable.- axes
Determines which axes will be drawn in case of fixed scales.When
"margins", axes will be drawn at the exterior margins."all_x"and"all_y"will drawthe respective axes at the interior panels too, whereas"all"(the default) will draw all axes at all panels.- scales
Should scales be fixed
"fixed", free ("free"), or free in one dimension ("free_x","free_y")?Defaults to"free"when providing one splitting variable viaby.Defaults to"fixed"when providing two splitting variables viarowsandcols.- ...
Arguments passed on to the
geomfunction.
Examples
# Before splittingenergy|>dplyr::filter(year%in%c(2005,2010,2015,2020))|>tidyplot(y=energy, color=energy_source)|>add_donut()|>adjust_size(width=25, height=25)
# Split by yearenergy|>dplyr::filter(year%in%c(2005,2010,2015,2020))|>tidyplot(y=energy, color=energy_source)|>add_donut()|>adjust_size(width=25, height=25)|>split_plot(by=year)
# Change dimensions of subplotsenergy|>dplyr::filter(year%in%c(2005,2010,2015,2020))|>tidyplot(y=energy, color=energy_source)|>add_donut()|>adjust_size(width=15, height=15)|>split_plot(by=year)
# Spread plots across multiple pagesenergy|>dplyr::filter(year%in%c(2005,2010,2015,2020))|>tidyplot(y=energy, color=energy_source)|>add_donut()|>adjust_size(width=25, height=25)|>split_plot(by=year, ncol=2, nrow=1)#>✔ split_plot: split into4 plots across2 pages#> [[1]]
#>#> [[2]]
#># Split by two variablesenergy|>dplyr::mutate(decade=paste0(floor(year/10)*10,"s"))|>tidyplot(y=energy, color=energy_source)|>add_donut()|>adjust_size(14,14)|>split_plot(rows=decade, cols=energy_type)