I have a time series taken from this 
How can i get a plot with only one title?
CodePudding user response:
You could hack the stats:::plot.decomposed.ts method and add a (expandable) dictionary as well as an add2main component.
plot.decomposed.ts <- function (x, lang=1L, add2main=NULL, ...) {
main <- matrix(c("Decomposition of", "Decomposizione della",
"time series", "serie storica"), 2L)[lang, ]
xx <- stats:::`%||%`(x$x, with(x, if (type == "additive")
random trend seasonal
else random * trend * seasonal))
plot(cbind(observed=xx, trend=x$trend, seasonal=x$seasonal,
random=x$random), main=paste(main[1L],
x$type, main[2L], add2main), ...)
}
plot(decompose(x), lang=2L, add2main='PIL US') ## 1L for EN, 2L for IT
Data:
x <- structure(c(-50, 175, 149, 214, 247, 237, 225, 329, 729, 809,
530, 489, 540, 457, 195, 176, 337, 239, 128, 102, 232, 429, 3,
98, 43, -141, -77, -13, 125, 361, -45, 184), .Tsp = c(1951, 1958.75,
4), class = "ts")

