Plot environmental contours showing depth-time patterns
Source: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.
Arguments
- dat
A dataframe from
pr_get_NRSEnvContour()containing environmental data formatted for contour plotting- na.fill
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)
Details
Contour plots are excellent for visualising:
Vertical Structure
Deep chlorophyll maximum (DCM) depth and intensity
Nutricline depth and strength
Stratification patterns (steep vs. gradual gradients)
Surface vs. subsurface maxima
Temporal Patterns
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
Gap Filling
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.
See also
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
Examples
dat <- pr_get_NRSEnvContour("Chemistry") %>% dplyr::filter(Parameters == "Nitrate_umolL",
StationCode %in% c('YON', 'MAI', 'PHB', 'NSI'))
plot <- pr_plot_NRSEnvContour(dat, na.fill = TRUE)