Skip to content

Error in adding multiple fables via autolayer #414

Description

@robjhyndman
library(fpp3)
#> Registered S3 method overwritten by 'tsibble':
#>   method               from 
#>   as_tibble.grouped_df dplyr
#> ── Attaching packages ─────────────────────────────────────── fpp3 1.0.1.9000 ──
#> ✔ tibble      3.2.1          ✔ tsibble     1.1.6     
#> ✔ dplyr       1.1.4          ✔ tsibbledata 0.4.1.9000
#> ✔ tidyr       1.3.1          ✔ feasts      0.4.1.9000
#> ✔ lubridate   1.9.4          ✔ fable       0.4.1.9000
#> ✔ ggplot2     3.5.1
#> ── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
#> ✖ lubridate::date()    masks base::date()
#> ✖ dplyr::filter()      masks stats::filter()
#> ✖ tsibble::intersect() masks base::intersect()
#> ✖ tsibble::interval()  masks lubridate::interval()
#> ✖ dplyr::lag()         masks stats::lag()
#> ✖ tsibble::setdiff()   masks base::setdiff()
#> ✖ tsibble::union()     masks base::union()
jan_vic_elec <- vic_elec |>
  filter(yearmonth(Time) == yearmonth("2014 Jan")) |>
  index_by(Date = as_date(Time)) |>
  summarise(Demand = sum(Demand), Temperature = max(Temperature))

fit <- jan_vic_elec |>
  model(TSLM(Demand ~ Temperature))

next_day_cold <- new_data(jan_vic_elec, 1) |>
  mutate(Temperature = 15)
f_cold <- fit |>
  forecast(next_day_cold) |>
  mutate(Scenario = "Cold day") |>
  as_fable(key = Scenario)

next_day_hot <- new_data(jan_vic_elec, 1) |>
  mutate(Temperature = 35)
f_hot <- fit |>
  forecast(next_day_hot) |>
  mutate(Scenario = "Hot day") |>
  as_fable(key = Scenario)

jan_vic_elec |>
  autoplot(Demand) +
  autolayer(bind_rows(f_cold, f_hot))
#> Error in `fill_alpha()`:
#> ! fill must be a vector of colours or list of <GridPattern> objects.

Created on 2025-02-04 with reprex v2.1.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions