CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 7
Time series visualization
Function temporalPlot
is a wrapper for the lattice (trellis) plot methods in lattice::xyplot
. Therefore, many different aspects of the plot can be controlled passing the relevant arguments to
xyplot
. Fine control of graphical parameters for the trellis display can
be also controlled using trellis.par.set
from package lattice
.
Additionally, includes its own parameters:
-
aggr.spatial
: Controls the function (and related arguments) to perform spatial aggregation. -
cols
: Controls the colors of the lines in each series. -
lwd
: Controls the width of the lines of the series. -
lty
: Controls the type of the lines of the series. -
show.na
: Paints with gray the background space corresponding to missing values.
Next we compare two time series, the first corresponds to a multimember grid (seasonal forecast, CFS_Iberia_pr) and the second to a grid without members (observational data, EOBS_Iberia_pr). Before plotting we apply function subsetGrid
from package transformeR
to choose the desired time interval.
library(transformeR)
data("CFS_Iberia_tas")
data("EOBS_Iberia_tas")
# Combine grids with members (CFS) and without members (EOBS)
a <- subsetGrid(CFS_Iberia_tas, years = 1985:1992)
b <- subsetGrid(EOBS_Iberia_tas, years = 1985:1992)
temporalPlot("EOBS" = b, "CFS" = a)
Note that in ``CFS'' the multimember spread (range) is indicated with a shadow of the same color. Also note that, since this datasets contain only winter data, there is a blank space for the rest of the stations.
We can introduce, and thus compare, as many grids (or station data) as we want in a single call. In addition, different time intervals can also be combined. For instance, next we add the time series of VALUE station data (VALUE_Iberia_pr), but considering a narrower time interval. In this case, we compute the spatial aggregation using function min
. We also use parameter xyplot.custom
to add several xyplot
parameters.
data("VALUE_Iberia_tas")
v <- subsetGrid(VALUE_Iberia_tas, years = 1988:1990)
temporalPlot("EOBS" = b, "CFS" = a, "VALUE" = v, lwd = 0.9,
aggr.spatial = list(FUN = min, na.rm = TRUE),
xyplot.custom = list(main = "winter temperature",
ylab = "Celsius", ylim = c(-20, 10)))
We can use subsetGrid to obtain and plot a single location (no spatial aggregation):
a1 <- subsetGrid(a, lonLim = 2, latLim = 42)
b1 <- subsetGrid(b, lonLim = 2, latLim = 42)
In the following example, we change the default colors of the series with parameter cols
. Option show.na = TRUE
(see above) is also used:
temporalPlot("EOBS" = b1, "CFS" = a1,
cols = c("green", "deeppink"), show.na = TRUE,
xyplot.custom = list(main = "winter temperature", ylab = "Celsius"))
visualizeR - Santander MetGroup (Univ. Cantabria - CSIC)