r - Lattice, xyplot, 2 time series on same graph (overlay) -
i want plot 2 time series on same graph, using xyplot.
here example of mean using ts.plot()
a1 = ts(rnorm(20), start=c(1980,1), freq=4) a2 = a1+3 ts.plot(a1,a2)
i have tried
xyplot(merge(a1,a2))
which returns error, , have tried
xyplot(merge(as.xts(a1),as.xts(a2)))
which plots them in different panels, not on same panel.
you can combine 2 time series objects using cbind
(or, alternatively, ts.union
). set superpose
argument in xyplot
true
:
xyplot(cbind(a1, a2), superpose = true)
short clarification: there s3 method xyplot
handles ts
(time series) objects. method (xyplot.ts
) gets called when x
argument xyplot
time series object.
Comments
Post a Comment