Skip to contents

Bivariate plots of 21st century climate change for user-selected locations and climate variables. The purposes of the plot are to:

  1. show differences in climate change trends among global climate models (GCMs);

  2. show the differences between multiple simulations of each model; and

  3. compare simulated climate change to observed climate change in the 2001-2020 period.

All climate changes are relative to the 1961-1990 reference period normals.

Usage

plot_bivariate(
  xyz,
  xvar = "Tave_sm",
  yvar = "PPT_sm",
  period_focal = list_gcm_periods()[1],
  gcms = list_gcms()[c(1, 4, 5, 6, 7, 10, 11, 12)],
  ssp = list_ssps()[2],
  obs_period = list_obs_periods()[1],
  gcm_periods = list_gcm_periods(),
  max_run = 10,
  legend_pos = "bottomleft",
  show_runs = TRUE,
  show_ensMean = TRUE,
  show_observed = TRUE,
  show_trajectories = TRUE,
  interactive = FALSE,
  cache = TRUE
)

Arguments

xyz

a terra::SpatRaster with a single layer containing elevation values in metres, or a data.frame with the following columns "long", "lat", "elev", and a unique "id". Any extra columns will be ignored and not output.

xvar

character. x-axis variable. options are list_vars().

yvar

character. y-axis variable. options are list_vars().

period_focal

character. The 20-year period for which to plot the ensemble detail. options are list_gcm_periods().

gcms

character. Vector of global climate model names. Options are list_gcms().

ssp

character. A single SSP-RCP scenario (representative concentration pathways paired with shared socioeconomic pathways). Options are list_ssps(). Defaults to SSP2-4.5.

obs_period

character. A single 20-year period for observed climate data. Options are list_obs_periods().

gcm_periods

character. 20-year reference periods for GCM simulations. Options are list_gcm_periods().

max_run

integer. Maximum number of model runs to include, not including the ensemble mean. Runs are included in the order they are found in the models data until max_run is reached. Defaults to 0L.

legend_pos

character. Position of the legend. Options are c("bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right", "center").

show_runs

logical. If TRUE, the individual runs of the model are plotted (for period_focal only) in addition to the single-model ensemble mean.

show_ensMean

logical. If TRUE, the multi-model ensemble mean is plotted (for period_focal only).

show_observed

logical. If TRUE, the 2001-2020 observed climate is plotted.

show_trajectories

logical. If TRUE, the values of the single-model ensemble mean are plotted for all 20-year periods in list_gcm_periods(), connected by an interpolation spline.

interactive

logical. If TRUE, an interactive plot is generated using {plotly}. If FALSE, a plot is generated using base graphics.

cache

logical. Cache data locally? Default TRUE

Value

NULL. Draws a plot in the active graphics device.

Details

The input table xyz can be a single location or multiple locations. If multiple locations, the plot provides the mean of the anomalies for these locations. The climate change trajectories provided by show_trajectories are points for each of the five 20-year periods specified by list_gcm_periods(). These points are connected with an interpolation spline when the x variable is monotonic; otherwise the trajectory points are connected by straight lines. This plot is designed to be used with a single SSP scenario. If multiple scenarios are passed to the plot, the GCM means and ensemble mean are averaged across the scenarios, but the individual runs for all scenarios are plotted separately.

Examples

# data frame of arbitrary points on Vancouver Island
my_points <- data.frame(
  lon = c(-123.4404, -123.5064, -124.2317),
  lat = c(48.52631, 48.46807, 49.21999),
  elev = c(52, 103, 357),
  id = seq_len(3)
)

# draw the plot
plot_bivariate(my_points)
#> Welcome to climr!
#> Getting observed anomalies...
#> Getting GCMs...
#> Downscaling in database...
#> Extracting [73] bands from refmap_climr
#> Extracting [1,980] bands from gcm_access-esm1-5
#> Extracting [1,080] bands from gcm_cnrm-esm2-1
#> Extracting [1,080] bands from gcm_ec-earth3
#> Extracting [720] bands from gcm_gfdl-esm4
#> Extracting [900] bands from gcm_giss-e2-1-g
#> Extracting [720] bands from gcm_miroc6
#> Extracting [540] bands from gcm_mpi-esm1-2-hr
#> Extracting [360] bands from gcm_mri-esm2-0
#> Extracting [36] bands from historic_periods


# draw an interactive (plotly) plot
plot_bivariate(my_points, xvar="MAT", yvar="PAS", interactive = TRUE)
#> Welcome to climr!
#> Getting observed anomalies...
#> Getting GCMs...
#> Downscaling in database...
#> Extracting [73] bands from refmap_climr
#> Extracting [1,980] bands from gcm_access-esm1-5
#> Extracting [1,080] bands from gcm_cnrm-esm2-1
#> Extracting [1,080] bands from gcm_ec-earth3
#> Extracting [720] bands from gcm_gfdl-esm4
#> Extracting [900] bands from gcm_giss-e2-1-g
#> Extracting [720] bands from gcm_miroc6
#> Extracting [540] bands from gcm_mpi-esm1-2-hr
#> Extracting [360] bands from gcm_mri-esm2-0
#> Extracting [36] bands from historic_periods
# export plot to a temporary directory figDir <- tempdir() png( filename = file.path(figDir, "plot_test.png"), type = "cairo", units = "in", width = 6, height = 5, pointsize = 10, res = 300 ) plot_bivariate(my_points) #> Welcome to climr! #> Getting observed anomalies... #> Getting GCMs... #> Downscaling in database... #> Extracting [73] bands from refmap_climr #> Extracting [1,980] bands from gcm_access-esm1-5 #> Extracting [1,080] bands from gcm_cnrm-esm2-1 #> Extracting [1,080] bands from gcm_ec-earth3 #> Extracting [720] bands from gcm_gfdl-esm4 #> Extracting [900] bands from gcm_giss-e2-1-g #> Extracting [720] bands from gcm_miroc6 #> Extracting [540] bands from gcm_mpi-esm1-2-hr #> Extracting [360] bands from gcm_mri-esm2-0 #> Extracting [36] bands from historic_periods dev.off() #> pdf #> 2