autoplot() from fpp3 / fable shows black legend background for prediction intervals

I’m using the fpp3 framework (tsibble + fable + fabletools) to forecast time series data and plot the results with autoplot(). The code below is almost identical to the example from Forecasting: Principles and Practice (using aus_retail), but in my environment the legend background for the prediction intervals is solid black, instead of showing different fill colors for the intervals.

Here is a minimal reproducible example:

library(fpp3)
auscafe <- aus_retail |>
filter(stringr::str_detect(Industry, "Takeaway")) |>
summarise(Turnover = sum(Turnover))
train <- auscafe |>
filter(year(Month) <= 2013)
STLF <- decomposition_model(
STL(log(Turnover) ~ season(window = Inf)),
ETS(season_adjust ~ season("N"))
)
cafe_models <- train |>
model(
ets = ETS(Turnover),
stlf = STLF,
arima = ARIMA(log(Turnover))
) |>
mutate(combination = (ets + stlf + arima) / 3)
cafe_fc <- cafe_models |>
forecast(h = "5 years")

cafe_fc |>
autoplot(auscafe |> filter(year(Month) > 2008),
level = NULL) +
labs(y = "美元(十亿)",
title = "澳大利亚每月外出就餐支出",x="月份")+
scale_color_discrete(name="预测模型")

cafe_fc |> filter(Month == min(Month))

cafe_futures <- cafe_models |>

generate(h = "5 years", times = 1000) |>

as_tibble() |>
group_by(Month, .model) |>
summarise(
dist = distributional::dist_sample(list(.sim))
) |>
ungroup() |>

as_fable(index = Month, key = .model,
distribution = dist, response = "Turnover")

cafe_futures |>
filter(.model == "combination") |>
autoplot(auscafe |> filter(year(Month) > 2008)) +
labs(y = "美元(十亿)",
title = "澳大利亚每月外出就餐支出",x="月份")

The issue is with the last plot


Referred here by Forecasting: Principles and Practice, by Rob J Hyndman and George Athanasopoulos

See fable, tsibble, ggplot2, the Legend Key on the RHS fails to map forecast interval levels to fill aesthetics, defaulting to black - #3 by Amarjit_Chandhial
Try updating your packages

Thanks for your faster reply! This is a packages version problem. With your help, this problem has been solved: Fixed in both the development versions of ggplot2 and ggdist.# development version from GitHub:

install.packages("pak")

pak::pak("tidyverse/ggplot2")

install.packages("devtools")
devtools::install_github("mjskay/ggdist")

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.