rtime-seriesstl-decompositionautoplot

Editing the time series- decomposed plots


Is it possible to remove the empty grey boxes (highlighted inside red circle) present to the right side of the decomposed plots (attached)?

Also, it is possible to change the title fonts (highlighted inside green circle) of the individual to Times New Roman or any other fonds of choice?

The r code used for creating the plot is as below

autoplot(decompose(x, type = "additive"))+labs(y=expression(Chl[a]~(µg/L)), x="Year") + ggtitle(expression(Decomposed~Chl[a]~Time~Series~BB1)) + theme(plot.title=element_text(hjust=0.5))

time series- decomposed plots

time series- decomposed plots


Solution

  • In the forecast package it is not possible to position the scale bars on the left. You would have to remove the scale bars and add them to the left yourself manually. This can be done by setting autoplot(x, range.bars = FALSE).

    You can specify the font family in ggplot2 by setting the appropriate theme() text field to element_text(family = ***).

    I have used USAccDeaths as an example dataset here:

    library(fpp2)
    #> Registered S3 method overwritten by 'quantmod':
    #>   method            from
    #>   as.zoo.data.frame zoo
    #> ── Attaching packages ────────────────────────────────────────────── fpp2 2.4 ──
    #> ✓ ggplot2   3.3.5.9000     ✓ fma       2.4       
    #> ✓ forecast  8.15           ✓ expsmooth 2.3
    #> 
    autoplot(decompose(USAccDeaths, type = "additive"))+
      labs(y=expression(Chl[a]~(µg/L)), x="Year") + 
      ggtitle(expression(Decomposed~Chl[a]~Time~Series~BB1)) +
      theme(
        plot.title=element_text(hjust=0.5),
        text = element_text(family = "Times New Roman", size = 15)
      )
    

    Created on 2021-08-26 by the reprex package (v2.0.0)