MtsPlot: Multiple time series plot

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Allows to plot multiple time series with different y-axes into one plot. This function is an alternative approach to plot trends than plot.Trend. It is especially suited to plot trends of different variables with different units in one figure.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
MtsPlot(x, xlim = NULL, 
    rge = c(0, 1), ylim = NULL, 
    col = "blue", lwd = 1, 
    add = FALSE, axis = TRUE, 
    ylab = "x", axis.pos = "l", 
    axis.col = col, axis.lim = NULL, 
    trend = TrendAAT, 
    trend.period = NULL, 
    trend.text = 1, unit = "", 
    text = "", unc = "polygon", 
    ensfun = mean, ...)

Arguments

x

time series that should be plotted. If x has multiple columns, uncertainties can be plotted as individual 'lines' or as 'polygon' (see 'unc').

xlim

range of x-axis

rge

range of y-axis in which the time series should be plotted.

ylim

axis limits of the y-axis for the data in x

col

color of the time series and corresponding axis

lwd

line width of the time series

add

initialize a new plot if FALSE or adds time series to existing plot if TRUE

axis

draws a y-axis if TRUE

ylab

label for y-axis

axis.pos

position of y-axis: l (left) or r (right)

axis.col

color for the axis

axis.lim

limits (min/max) for the axis

trend

compute and adds a trend line using TrendText. Set to NULL for no trends.

trend.period

define a sub-period (e.g. c(1990, 2015)) to compute trends for the full time series and this period

trend.text

type of trend text to plot: 1 (trend in %), 2 (trend slope with unit), 3 (trend slope without unit), 4 (p-value from Mann-Kendall trend test), 5 (only if x has multiple columns: p-value Wilcoxon rank sum test). In case of other values, no text will be plotted. In case of trend.text=5, the Wilcoxon rank sum test is used to test if the ensmble of trend slopes for each column in x is significant different from 0.

unit

unit of the values in x (used for trend text)

text

additional text that should be plotted next to each time series

unc

if x has multiple columns, plot uncertainty ranges as 'polygon' or line'?

ensfun

if x has multiple columns, how to compute the main estimate of the emsemble?

...

further arguments to plot.default

Details

This function plots a scatterplot.

Value

A list with information about the estimated trend.

Author(s)

Matthias Forkel <matthias.forkel@tu-dresden.de> [aut, cre]

See Also

TrendText, plot.Trend

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
ndvi <- aggregate(ndvi, FUN=mean)

# default plot
MtsPlot(ndvi, ylab="NDVI")
MtsPlot(ndvi, ylab="NDVI", text="GIMMS")
MtsPlot(ndvi, rge=c(0.4, 1)) # plot time series in (0.4-1) range of y-axis
MtsPlot(ndvi, rge=c(0.5, 1), ylim=c(0,1)) # use (0-1) range for y-values and 
  # plot in (0.5-1) range of y-axis

# plot with uncertainty ranges
ndvi2 <- cbind(ndvi, ndvi * 1.3, ndvi * 0.7)
MtsPlot(ndvi2, rge=c(0.5, 1)) # uncertainty as polygon
MtsPlot(ndvi2, add=TRUE, rge=c(0, 0.5), unc="line", col="red",
        axis.pos="r") # uncertainty as line

# # plot multiple time series
# ndvi2 <- ndvi * 2 # scaled NDVI
# ndvi3 <- ndvi^2 # squared NDVI
# par(mar=c(3, 3, 2, 3))
# MtsPlot(ndvi, rge=c(0.66, 1), ylab="NDVI")
# MtsPlot(ndvi2, add=TRUE, rge=c(0.33, 0.66), axis.pos="r", ylab="NDVI*2", col="red")
# MtsPlot(ndvi3, add=TRUE, rge=c(0, 0.33), axis.pos="l", ylab="NDVI^2", col="purple")
# 
# # options for trend
# MtsPlot(ndvi, ylab="NDVI", trend=NULL) # no trend
# MtsPlot(ndvi, ylab="NDVI", trend.period=c(1982, 1996)) # compute trend in subperiod
# MtsPlot(ndvi, ylab="NDVI", trend.period=c(1982, 1996), 
#         unit="NDVI", trend.text=1) # text: trend in % (default)
# MtsPlot(ndvi, ylab="NDVI", trend.period=c(1982, 1996), 
#         unit="NDVI", trend.text=2) # text: trend in units
# MtsPlot(ndvi, ylab="NDVI", trend.period=c(1982, 1996), 
#         unit="NDVI", trend.text=3) # text: trend without unit
# MtsPlot(ndvi, ylab="NDVI", trend.period=c(1982, 1996), 
#         unit="NDVI", trend.text=4) # text: p-value only
# 
# ndvi2 <- cbind(ndvi, ndvi * 1.3, ndvi * 0.7)
# MtsPlot(ndvi2, ylab="NDVI", trend.period=c(1982, 1996), 
#         unit="NDVI", trend.text=5) # text: p-value only

greenbrown documentation built on Dec. 18, 2020, 3:02 p.m.