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(
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
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()
. Defaults toNULL
.- 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()
. Defaults toNULL
.- max_run
integer. Maximum number of model runs to include. A value of 0 returns the
ensembleMean
only. Runs are included in the order they are found in the models data untilmax_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 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 = LETTERS[1:3]
)
# draw the plot
plot_bivariate(my_points)
#> Welcome to climr!
#> Getting normals...
#> Not fully cached :( Will download more
#> Downloading new data...
#> .
#> Caching data...
#> Getting observed anomalies...
#> Not fully cached :( Will download more
#> Downloading observed period anomalies
#> .
#> Caching data...
#> Getting GCMs...
#> Not fully cached :( Will download more
#> Downloading GCM anomalies
#> Caching data...
#> Downloading GCM anomalies
#> .
#> Caching data...
#> Not fully cached :( Will download more
#> Downloading GCM anomalies
#> .
#> Caching data...
#> Not fully cached :( Will download more
#> Downloading GCM anomalies
#> .
#> Caching data...
#> Downloading GCM anomalies
#> .
#> Caching data...
#> Downloading GCM anomalies
#> .
#> Caching data...
#> Downloading GCM anomalies
#> .
#> Caching data...
#> Downloading GCM anomalies
#> .
#> Caching data...
#> Downscaling!!
# draw an interactive (plotly) plot
if (interactive()) {
plot_bivariate(my_points, interactive = TRUE)
}
# 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 normals...
#> Retrieving from cache...
#> Getting observed anomalies...
#> Retrieving from cache...
#> Getting GCMs...
#> Retrieving from cache...
#> Retrieving from cache...
#> Retrieving from cache...
#> Retrieving from cache...
#> Retrieving from cache...
#> Retrieving from cache...
#> Retrieving from cache...
#> Retrieving from cache...
#> Downscaling!!
dev.off()
#> agg_png
#> 2