autoplot_anomaly_ts: Wrapper function to calculate and plot timerseries of indices...

Description Usage Arguments Details See Also Examples

View source: R/autoplot_ts_stations_anom.R View source: R/autoplot_anomaly_ts.R

Description

The function calls calc_index and returns an anomaly timeseries plot with different options for indices and aggregation described below.
At the moment the function does not have the options to plot trends, please use autoplot_ts_stations for plotting trends.

The function calls calc_index and returns an anomaly timeseries plot with different options for indices and aggregation described below.
At the moment the function does not have the options to plot trends, please use autoplot_ts_stations for plotting trends.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
autoplot_anomaly_ts(
  dat_p,
  index,
  index_args,
  ts_type = "single_ts",
  selpoints = NULL,
  refyears = NULL,
  output = NULL,
  plotdir = NULL,
  plotname = NULL,
  title = "",
  plot_title = TRUE,
  plot_legend = TRUE,
  ylims = NULL,
  pwidth = 2000,
  pheight = 1300,
  pres = 250,
  cex = 1,
  text_cex = 1,
  ...
)

autoplot_anomaly_ts(
  dat_p,
  index,
  index_args,
  ts_type = "single_ts",
  selpoints = NULL,
  refyears = NULL,
  output = NULL,
  plotdir = NULL,
  plotname = NULL,
  title = "",
  plot_title = TRUE,
  plot_legend = TRUE,
  ylims = NULL,
  pwidth = 2000,
  pheight = 1300,
  pres = 250,
  cex = 1,
  text_cex = 1,
  ...
)

Arguments

dat_p

A Climindvis-object with type = "p" generated by make_object. For ts_type="multi_dat" dat_p is a list of climindivs-objects with type = "p" or "p_hc".

index

Name of index to be calculated or array of indices to be calculated for ts_type = "multi_ind".

index_args

List of arguments for index. See calc_index.
For ts_type = "multi_ind", index_args is a list containing a list of index arguments for each of the indices.
For ts_type="multi_agg" index_args is a list containing a list of index arguments for each aggregation type (e.g. if you want to compare annual and seasonal values type index_args=list(list(aggt="annual"),list(aggt="seasonal")).

ts_type

Type of time series plot to be drawn:

  • "single_ts" plots one index for one dataset. Returns a seperate plot for each station and each aggregation.

  • "multi_ind" plots several indices for one dataset. Returns a seperate plot for each station and each aggregation. (Ensemble not implemented).

  • "multi_agg" plots one index and one dataset. Returns a seperate plot for each station and combines aggregation values in one plot. (Ensemble not implemented).

  • "multi_point" plots one index and one dataset. Returns a seperate plot for each aggregation value and combines several stations in one plot (either all stations or a subset to be specified in selpoints). (Ensemble not implemented).

  • "multi_dat" plots one index for multiple datasets (e.g. observations, reanalyses and hindcasts). Returns a seperate plot for each station and each aggregation. If ensemble data is provided, the spread of the ensemble members is plotted.

selpoints

Array to select subset of points to plot. There are two options:

  • Character array of station names (works only if names are defined in climindvis_index objects ...$data_info$pnames and if they are the same for all objects in climindvis_index_list)

  • Integer array of station indices (works only if coordinates of all objects in climindvis_index_list are the same)

refyears

Integer array of reference years for calculation of anomaly. Default=1981:2010

output

Format of image to be plotted ("png", "jpeg", "tiff", "pdf","dev.new"). Default = NULL, output to null device (getOption("device") will show you the null device. If you are not using RStudio, NULL and dev.new will give the same output).

plotdir

Character string of path of directory for saving plots. Ignored if output is NULL or "dev.new".

plotname

Optional. Character string. First part of plot name followed by character string containing index name/aggregation/time period/... depending on the autoplot function. Default = "".

title

Optional. Character string. If provided added above the plot in addition to default information from the respective function (e.g. index name/aggregation/time period/...). Default = "", no additional title is written.

plot_title

Logical. Add plot title and additional information to graphic? Default = TRUE.

plot_legend

Logical. Add plot legend of depicted stations to graphic? Default = TRUE.

ylims

Limits of xaxis for plot of format ylims=c(ymin,ymax). If a individual limits for every plot are needed, set ylims to "ind". If not provided limits are taken from the data and are equal in all plots.

pwidth

Width of plotting region of output (as input for jpeg, png, ...). For output = pdf, pwidth is set to pwidth/pres. Default = 2000.

pheight

Height of plotting region of output (as input for jpeg, png, ...). For output = pdf, pheight is set to pheight/pres. Default = 1300.

pres

Graphics resolution. Default = 250.

cex

cex of plots (see par()). Default=1

text_cex

size of text plotted in graph. Default=1

...

Optional parameters for shading. Shading only works for type = "single_ts"

  • pcols Array of colors with required length, e.g. 1 for a single timeseries and number of indices, aggregations, points, datasets for <ts_type>. If no colors are provided, colors are set to default colors.

  • shading Optional. Logical. Add shading of areas for different areas of y-values to plot ? If TRUE nshading ( and yval_shading) need to be provided. See Details for more information.

  • nshading Optional. Number of shading categories.

  • yval_shading Optional. Array of the same length as nshading+1 with user defined y-limits for shading polygons.

  • col_shading Optional. Color for shading. Array of same length as nshading.

Details

The missing values displayed when plot_title = TRUE denotes the percentage of missing daily values in the selected aggregation period.

By passing the optional parameters shading, nshading (ycal_shading) and col_shading to the function, horizontal shading polygons can be added to the plot.
For example, to mark the area below zero in blue and the one above zero in red when looking at temperature indices such as maximum teperatures one has to pass the following values to the function: shading=TRUE, nshading=2, yval_shading=c(-999,0,999), col_shading=c("blue","red").
If you want to add equidistant shading categories (e.g. if you issue a tercile forecast and want to show the corresponding values in the climatology you just need to specify nshading which would be equal to the number of forecast categories and the function calculates the corresponding category thresholds. This is used e.g. by the autoplot_forecast_stations function when plot_climatology=TRUE.

Trendplots are currently not implemented in this function.

The missing values displayed when plot_title = TRUE denotes the percentage of missing daily values in the selected aggregation period.

By passing the optional parameters shading, nshading (ycal_shading) and col_shading to the function, horizontal shading polygons can be added to the plot.
For example, to mark the area below zero in blue and the one above zero in red when looking at temperature indices such as maximum teperatures one has to pass the following values to the function: shading=TRUE, nshading=2, yval_shading=c(-999,0,999), col_shading=c("blue","red").
If you want to add equidistant shading categories (e.g. if you issue a tercile forecast and want to show the corresponding values in the climatology you just need to specify nshading which would be equal to the number of forecast categories and the function calculates the corresponding category thresholds. This is used e.g. by the autoplot_forecast_stations function when plot_climatology=TRUE.

Trendplots are currently not implemented in this function.

See Also

Other autoplot_functions: autoplot_anomaly_map(), autoplot_climatology_map(), autoplot_forecast_map(), autoplot_forecast_spi(), autoplot_forecast_stations(), autoplot_overview_stations(), autoplot_trend_map(), autoplot_ts_stations(), autoplot_verification_map()

Other autoplot_functions: autoplot_anomaly_map(), autoplot_climatology_map(), autoplot_forecast_map(), autoplot_forecast_spi(), autoplot_forecast_stations(), autoplot_overview_stations(), autoplot_trend_map(), autoplot_ts_stations(), autoplot_verification_map()

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
 data("object_st","object_hc_st") # load example data
plotdir="./" # define a plot directory here or change output to NULL or "dev.new".

## ts_type = single_ts
autoplot_anomaly_ts(
      object_st, index = "sdii",
      index_args = list(aggt = "other", aggmons = c(1:3)),
      ts_type = "single_ts", pcols = "royalblue",
      output = "png", plotdir = plotdir, plotname = Sys.Date())

 # add shading
autoplot_anomaly_ts(
      object_st, index = "tnn",
      index_args = list(aggt = "other", aggmons = c(4)),
      ts_type = "single_ts", pcols = "royalblue", selpoints=2,
      shading = TRUE, nshading = 2, yval_shading = c(-999,0,999),col_shading = c("blue","red"),
      output = "png", plotdir = plotdir, plotname = Sys.Date())

## ts_type = multi_ind
index = c("txn", "txx","dd")
index_args = list(
      txn = list(aggt = "other", aggmons = c(1:3)),
      txx = list(aggt = "other", aggmons = c(1:3)),
      tnx = list(aggt = "other", aggmons = c(1:3)))
autoplot_anomaly_ts(
      dat_p = object_st, index = index, index_args = index_args,
      ts_type = "multi_ind",
      output = "png", plotdir = plotdir, plotname = Sys.Date())


## ts_type = "multi_agg"
index_args = list (
      list(aggt="seasonal",selagg=c("MAM")),
      list(aggt="monthly", selagg=c("1","2","3")))
autoplot_anomaly_ts(
      object_st, index = list("txn"), index_args=index_args,
      ts_type = "multi_agg",
      output = "png", plotdir = plotdir)


## ts_typ = "multi_point"
autoplot_anomaly_ts(
      object_st, c("dd"), index_args=list(aggt = "other", aggmons = c(1:2)),
      ts_type = "multi_point", selpoints=c(2,3),
      output = "png", plotdir = plotdir, plot_title = FALSE)

## ts_type = "multi_dat"
autoplot_anomaly_ts(
     list(object_st, object_hc_st), index = "txn", index_args=list(aggt="monthly", selagg=5),
     ts_type = "multi_dat",
     output = "png", plotdir = plotdir, plotname = Sys.Date())
 data("object_st","object_hc_st") # load example data
plotdir="./" # define a plot directory here or change output to NULL or "dev.new".

## ts_type = single_ts
autoplot_anomaly_ts(
      object_st, index = "sdii",
      index_args = list(aggt = "other", aggmons = c(1:3)),
      ts_type = "single_ts", pcols = "royalblue",
      output = "png", plotdir = plotdir, plotname = Sys.Date())

 # add shading
autoplot_anomaly_ts(
      object_st, index = "tnn",
      index_args = list(aggt = "other", aggmons = c(4)), 
      ts_type = "single_ts", pcols = "royalblue", selpoints=2,
      shading = TRUE, nshading = 2, yval_shading = c(-999,0,999),col_shading = c("blue","red"),
      output = "png", plotdir = plotdir, plotname = Sys.Date())

## ts_type = multi_ind
index = c("txn", "txx","dd")
index_args = list(
      txn = list(aggt = "other", aggmons = c(1:3)),
      txx = list(aggt = "other", aggmons = c(1:3)),
      tnx = list(aggt = "other", aggmons = c(1:3)))
autoplot_anomaly_ts(
      dat_p = object_st, index = index, index_args = index_args,
      ts_type = "multi_ind", 
      output = "png", plotdir = plotdir, plotname = Sys.Date())


## ts_type = "multi_agg"
index_args = list (
      list(aggt="seasonal",selagg=c("MAM")),
      list(aggt="monthly", selagg=c("1","2","3")))
autoplot_anomaly_ts(
      object_st, index = list("txn"), index_args=index_args,
      ts_type = "multi_agg",
      output = "png", plotdir = plotdir)


## ts_typ = "multi_point"
autoplot_anomaly_ts(
      object_st, c("dd"), index_args=list(aggt = "other", aggmons = c(1:2)),
      ts_type = "multi_point", selpoints=c(2,3),
      output = "png", plotdir = plotdir, plot_title = FALSE)

## ts_type = "multi_dat"
autoplot_anomaly_ts(
     list(object_st, object_hc_st), index = "txn", index_args=list(aggt="monthly", selagg=5),
     ts_type = "multi_dat", 
     output = "png", plotdir = plotdir, plotname = Sys.Date())

Climandes/ClimIndVis documentation built on Oct. 24, 2021, 10:52 a.m.