R/plot_enviro.R
pr_plot_NRSEnvContour.RdCreate contour plots showing how environmental variables change with both time (x-axis) and depth (y-axis). This visualisation is particularly effective for identifying vertical structure, stratification, and the deep chlorophyll maximum.
pr_plot_NRSEnvContour(df, na.fill = TRUE)A dataframe from pr_get_NRSEnvContour() containing environmental
data formatted for contour plotting
How to handle missing data (gaps) in the contour:
TRUE - Fill gaps using linear interpolation (default, creates smoother contours)
FALSE - Leave gaps as-is (shows only measured data)
A function - Use custom interpolation (e.g., mean, median)
A ggplot2 object with contour plots faceted by station and parameter
Contour plots are excellent for visualising:
Deep chlorophyll maximum (DCM) depth and intensity
Nutricline depth and strength
Stratification patterns (steep vs. gradual gradients)
Surface vs. subsurface maxima
Seasonal shoaling/deepening of features
Upwelling events (nutrient-rich water at surface)
Mixing events (homogenisation of the water column)
Long-term changes in vertical structure
When na.fill = TRUE, the function uses metR::geom_contour_fill() with
linear interpolation to create smooth contours. This is appropriate for
environmental data with regular sampling patterns and small gaps. For irregular
sampling or large gaps, consider setting na.fill = FALSE to show only measured
data.
The function automatically creates one facet per station and parameter combination. Contours are filled with a colour scale, and contour lines are overlaid in grey.
pr_get_NRSEnvContour() for preparing the input data,
pr_plot_Enviro() for alternative line plot visualisation,
pr_get_NRSChemistry(), pr_get_NRSPigments(), pr_get_NRSPico() for data sources
df <- pr_get_NRSEnvContour("Chemistry") %>% dplyr::filter(Parameters == "Nitrate_umolL",
StationCode %in% c('YON', 'MAI', 'PHB', 'NSI'))
plot <- pr_plot_NRSEnvContour(df, na.fill = TRUE)