Home > database >  How to replace a title in a plot
How to replace a title in a plot

Time:01-29

I have a time series taken from this Plot

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

enter image description here


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")
  •  Tags:  
  • Related