Change legend title of forecast plot

In the following example, how do I change the legend titles? For example, level becomes Level; .model becomes Forecast.

library(fpp3)

us_change %>%
  model(model1 = ARIMA(Consumption ~ PDQ(0,0,0)),
        model2 = ARIMA(Consumption ~ PDQ(1,0,0))) %>% 
  forecast(h = 36) %>% 
  autoplot(us_change)

Created on 2020-11-24 by the reprex package (v0.3.0)

This is changes level. Not sure about changing model.

us_change %>%
  model(model1 = ARIMA(Consumption ~ PDQ(0,0,0)),
        model2 = ARIMA(Consumption ~ PDQ(1,0,0))) %>% 
  forecast(h = 36) %>% 
  autoplot(us_change) +
  labs(level = "Level")

Now I would like to get rid of .model legend.

library(fpp3)

us_change %>%
  model(model1 = ARIMA(Consumption ~ PDQ(0,0,0)),
        model2 = ARIMA(Consumption ~ PDQ(1,0,0))) %>% 
  forecast(h = 36) %>% 
  autoplot(us_change) +
  guides(colour = guide_legend(title = "Forecast")) +
  labs(level = "Level")

Created on 2020-11-25 by the reprex package (v0.3.0)

library(fpp3)

us_change %>%
  model(model1 = ARIMA(Consumption ~ PDQ(0,0,0)),
        model2 = ARIMA(Consumption ~ PDQ(1,0,0))) %>% 
  forecast(h = 36) %>% 
  autoplot(us_change) +
  guides(
    colour = guide_legend(title = "Forecast"),
    fill = guide_legend(title = "Forecast")
  ) +
  labs(level = "Level")

Created on 2020-11-26 by the reprex package (v0.3.0)

1 Like

Thanks a lot!Just what I was looking for :smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.