View source: R/plotSizeCompsAsRidges.R
plotSizeCompsAsRidges | R Documentation |
Function to plot annual size comps (or other similar) using ggridges
plotSizeCompsAsRidges(
dfr_,
sizes_in = "size",
values_in = "abundance",
y_positions = "year",
removeZeros = TRUE,
reverseY = FALSE,
colour = NULL,
fill = NULL,
group_by = y_positions,
normalize_by = NULL,
xlim = c(100, 200),
ylim = c(1980, 2022),
x_breaks = seq(5, 200, 5),
y_breaks = seq(1900, 2100, 5),
legend.position = c(0.98, 0.98),
legend.justification = c(1, 1)
)
dfr_ |
- input dataframe |
sizes_in |
- name of column with "size" information (default = "size") |
values_in |
- name of column with "abundance" information (default = "abundance") |
y_positions |
- name of column with vertical axis location information (default = "year") |
removeZeros |
- remove comps with zero abundance in all bins(default = TRUE) |
reverseY |
- reverse y scale (default = FALSE) |
colour |
- column name for colour variable (default = NULL) |
fill |
- column name for fill variable (default = NULL) |
group_by |
- string vector with column names for grouping before summarizing (default = value of y_positions) |
normalize_by |
- string vector with column names for grouping before normalizing (default = NULL) |
xlim |
- x axis limits (default = c(0,200)) |
ylim |
- y axis limits (default = c(1980,2022)) |
x_breaks |
- x axis breaks (default = seq(5,200,5)) |
y_breaks |
- y axis breaks (default = seq(1900,2100,5)) |
legend.position |
- legend position (as in [ggplot2::theme()], default = c(0.98,0.98)) |
legend.justification |
- legend justification on plot (as in [ggplot2::theme()], default = c(1,1)) |
Uses [ggridges::geom_density_ridges()] to plot the size compositions. The returned plot object can be faceted, etc., for more complex plotting situations.
Aggregation will be performed after grouping the data using [dplyr::group_by()], where the grouping structure is a combination of the variables specified in 'group_by', 'colour', and 'fill'.
ggplot2 plot object
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.