Bivariate climate change plots
plot_bivariate.Rd
Bivariate plots of 21st century climate change for user-selected locations and climate variables. The purposes of the plot are to:
show differences in climate change trends among global climate models (GCMs);
show the differences between multiple simulations of each model; and
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(
X,
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
- X
A
data.table
object produced using the functionplot_bivariate_input()
. This table can include more models, scenarios, and variables than are used in individual calls toplot_bivariate()
.- 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
Details
The input table X
provides climate data for a single location or the average of multiple
locations. The purpose of conducting the generation of the input table in a separate function is
to allow users to make multiple calls to plot_timeSeries()
without needing to generate the
inputs each time.
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.table(
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)
)
#> Error in data.table(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)): could not find function "data.table"
# draw the plot
plot_bivariate(my_points)
#> Error: object 'my_points' not found
# draw an interactive (plotly) plot
plot_bivariate(my_points, xvar="MAT", yvar="PAS_an", interactive = TRUE)
#> Error: object 'my_points' not found
# 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)
#> Error: object 'my_points' not found
dev.off()
#> agg_record_1533633155
#> 2