Skip to contents

Compare a survey timeseries numbers- and biomass- at length to visualize cohorts and compare trends over time. Because abundances can vary greatly over time, there are options to transform abundance values for more informative ridgeline plots. To be comparable to our typical plots, you can summarize your biomass and numbers as biomass (thousand tons) and numbers (million fish) by 1-cm length bins.

Usage

plot_historical_biomass_nums_length_ridges(
  survey_year_vector,
  length_vector,
  biomass_vector,
  numbers_vector,
  numbers_scale_transform = NULL,
  biomass_scale_transform = NULL
)

Arguments

survey_year_vector

A vector identifying the year a given numbers or abundance value is from. This vector must be equal in length to length_vector, biomass_vector, and numbers_vector.

length_vector

A vector of fish lengths (units are assumed to be cm). This vector must be equal in length to survey_year_vector, biomass_vector, and numbers_vector.

biomass_vector

A vector of fish weights (units are not specified, but should be consistent.) This vector must be equal in length to survey_year_vector, length_vector, and numbers_vector.

numbers_vector

A vector of fish numbers (units are not specified, but should be consistent.) This vector must be equal in length to survey_year_vector, length_vector, and biomass_vector.

numbers_scale_transform

An optional transformation for the numbers values; options are "log10" and "sqrt".

biomass_scale_transform

An optional transformation for the numbers values; options are "log10" and "sqrt".

Value

A ggplot plot object.

Examples

if (FALSE) { # \dontrun{
library(MACEReports)
library(dplyr)
data("pollock_length_weight_age_data")
# summarize by year, 1 cm length bins
plot_data <- pollock_length_weight_age_data %>%
mutate(length_bin = round(FORK_LENGTH, digits = 0),
       year = as.numeric(substr(SURVEY, 1, 4))) %>%
group_by(year, length_bin) %>%
summarize(biomass = sum(ORGANISM_WEIGHT),
          numbers = n())

#return a plot
ridgeline_plot <- plot_historical_biomass_nums_length_ridges(survey_year_vector = plot_data$year,
length_vector = plot_data$length_bin,
biomass_vector = plot_data$biomass,
numbers_vector = plot_data$numbers)

#plot it
ridgeline_plot
} # }