Description Usage Arguments Details See Also Examples
View source: R/autoplot_ts_stations.R
The function calls calc_index
and returns a timeseries plot with different options for indices and aggregation described below.
To see some example outputs of this function, look at the vignette "autoplot-functions" accessible through the package help main page or by typing
vignette("autoplot-functions",package="ClimIndVis") into the console.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | autoplot_ts_stations(
dat_p,
index,
index_args,
ts_type = "single_ts",
trendplots = FALSE,
selpoints = NULL,
selyears = 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,
...
)
|
dat_p |
A Climindvis-object with type = "p" generated by |
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 |
ts_type |
Type of time series plot to be drawn:
|
trendplots |
Logical. Plot trend line and 95% confidence interval for index. Default = FALSE. |
selpoints |
Array to select subset of points to plot. There are two options:
|
selyears |
Array to select subset of years to plot, e.g. c(1981:1990). |
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"
|
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.
If you set trendplots = TRUE, a trend line with confidence interval is added to the plot. For every index a default method is used for the trend calculation. The default trend estimation and test depends on the nature of the calculated index: For continuous data (e.g. sum, mean, prcptot, spi) by default an ordinary linear regression is calculated, for count data (e.g dd, cdd, cwd) a logistic regression with time as predictor for the trend estimation and applying a students-t test for significance testing. If you set trend = "MannKendall" inside the list of index arguments (index_args), the non-parametric Mann-Kendall test based on the relative ranking in the series is applied and a Theil-Sen slope is estimated. See e.g. Yue et al. 2002 or Mann (1945), Kendall (1975) for further references.
Other autoplot_functions:
autoplot_anomaly_map()
,
autoplot_anomaly_ts()
,
autoplot_climatology_map()
,
autoplot_forecast_map()
,
autoplot_forecast_spi()
,
autoplot_forecast_stations()
,
autoplot_overview_stations()
,
autoplot_trend_map()
,
autoplot_verification_map()
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 | 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_ts_stations(
object_st, index = "sdii",
index_args = list(aggt = "other", aggmons = c(1:3)), trendplots=TRUE,
ts_type = "single_ts", pcols = "royalblue", ylims = c(0,30),
output = "png", plotdir = plotdir, plotname = Sys.Date())
# add shading
autoplot_ts_stations(
object_st, index = "tnn",
index_args = list(aggt = "other", aggmons = c(4)), trendplots = TRUE,
ts_type = "single_ts", pcols = "royalblue", ylims = c(-10,20), 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_ts_stations(
dat_p = object_st, index = index, index_args = index_args,
ts_type = "multi_ind", trendplots = TRUE,
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_ts_stations(
object_st, index = list("txn"), index_args=index_args,
ts_type = "multi_agg",
output = "png", plotdir = plotdir)
## ts_typ = "multi_point"
autoplot_ts_stations(
object_st, c("dd"), index_args=list(aggt = "other", aggmons = c(1:2)),
ts_type = "multi_point", trendplots = TRUE, selpoints=c(2,3),
output = "png", plotdir = plotdir, plot_title = FALSE, ylims = c(0,100))
## ts_type = "multi_dat"
autoplot_ts_stations(
list(object_st, object_hc_st), index = "txn", index_args=list(aggt="monthly", selagg=5),
ts_type = "multi_dat", trendplots = FALSE,
output = "png", plotdir = plotdir, plotname = Sys.Date())
## ts_type = "spi_barplot"
autoplot_ts_stations(
object_st, index = "spi", index_args=list(aggt="monthly"),
ts_type = "spi_barplot", plot_title = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.