Search code examples
rtime-seriesvisualizationforecast

Is it possible to change font sizes in forecast::autoplot()?


In order to make a time series app with plot for analysis, I want to use the autoplot function of the forecast package, to provide stl decomposition.

However, it seems like there is no functionality given, to resize the text size of x and y axis. The base plot() arguments have no effect:

library(forecast)

co2 %>% 
decompose() %>% 
autoplot(
         cex.lab = 11,
         cex.axis = 11,
         cex.main = 13,
         cex.sub = 13)

Solution

  • autoplot comes from ggplot2. So you will need to use the ggplot2 functions to adjust items from the autoplot.

    E.g. for adjusting the title size:

    co2 %>% 
      decompose() %>% 
      autoplot() +
      theme(title = element_text(size = 13)
            )