[R] Plot multiple time series on a seasonal plot

Jérôme François ld1083-r @ending from y@hoo@com
Fri Jun 29 15:41:19 CEST 2018


Dear members,

I would like to plot a second time series (a forecast) to a seasonal plot made with function seasonplot() from the package forecast.


Here is a reproducible example:
ts1 <- structure(c(112035, 111182, 111015, 109331, 107525, 107749, 111435, 
111629, 112462, 112256, 109496, 107917, 108221, 107463, 105960, 
103883, 101038, 100056, 101628, 102973, 103371, 102463, 100774, 
100718, 100471, 99828, 99365, 98521, 95695, 96443, 96287, 97525, 
98293, 98014, 96658, 96736, 96089, 95337, 95382, 92748, 91448, 
91560, 92996, 94046, 94128, 93888, 93888, 91091, 91877, 91681, 
91045, 89367, 87912), .Tsp = c(2014, 2018.33333333333, 12), class = "ts")

ts2 <- structure(c(87867.2152330971, 89713.0862474283, 89600.565347383, 
91066.3196835822, 90523.1926861474, 89322.8025396445, 88771.5545520503, 
89247.0913151542, 88803.5578121458, 88060.0948570082, 87015.6578227365, 
85785.4121532206), .Tsp = c(2018.41666666667, 2019.33333333333, 
12), class = "ts")


library(forecast)seasonplot(ts1, year.labels = TRUE, year.labels.left = TRUE)


How can I add ts2 to the seasonal plot? I would like it to be distinguishable from ts1 (e.g. different color).

lines(ts2) doesn't work.
Thank you.
Sincerely,

Jérôme



More information about the R-help mailing list