R/plot_timeseries.R
pr_plot_Climatology.RdCreate bar plots showing monthly or annual climatologies (mean values with error bars) to examine seasonal cycles or interannual variability in plankton indices. Data are aggregated across years (monthly) or within years (annual) to show typical patterns.
pr_plot_Climatology(df, Trend = "Month", trans = "identity")A dataframe from pr_get_Indices() containing timeseries data
The temporal aggregation for climatology:
"Month" - Monthly climatology averaged across all years (shows seasonal patterns)
"Year" - Annual means for each year (shows interannual variability)
Transformation for the y-axis scale:
"identity" - No transformation (default)
"log10" - Log base 10 transformation (useful for abundance data)
"sqrt" - Square root transformation
Any other transformation accepted by ggplot2::scale_y_continuous()
A ggplot2 bar plot with error bars showing climatology patterns
Calculates the mean value for each month across all years in the dataset. This shows the typical seasonal cycle, useful for identifying:
Spring phytoplankton blooms
Summer stratification effects
Winter mixing impacts
Seasonal migration patterns in zooplankton
Calculates the mean value for each calendar year. This shows year-to-year variability, useful for identifying:
Long-term trends (increasing or decreasing)
Regime shifts
Responses to climate oscillations (e.g., ENSO, SAM)
Extreme years (e.g., marine heatwaves)
Error bars represent standard error of the mean (±SE), calculated as SD/√N where N is the number of observations.
For NRS data, values are averaged across depths if present.
pr_plot_Trends() for alternative climatology visualisation with trend lines,
pr_plot_TimeSeries() for raw time series plots
df <- pr_get_Indices(Survey = "NRS", Type = "Phytoplankton") %>%
dplyr::filter(Parameters == "PhytoBiomassCarbon_pgL", StationCode %in% c("NSI", "PHB"))
monthly <- pr_plot_Climatology(df, Trend = "Month")
df <- pr_get_Indices(Survey = "CPR", Type = "Zooplankton") %>%
dplyr::filter(Parameters == "ZoopAbundance_m3")
annual <- pr_plot_Climatology(df, Trend = "Year")