From 6865b67b06886adba6ab3486fde0dd5d3e35f7c1 Mon Sep 17 00:00:00 2001 From: mitchelloharawild Date: Mon, 13 May 2024 12:37:45 +1000 Subject: [PATCH] Fixed issue with `autoplot()` and length 1 forecasts Resolves #400 --- NEWS.md | 4 ++++ R/plot.R | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5d5fb873..e473bb11 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # fabletools (development version) +## Bug fixes + +* Fixed issue with `autoplot()` and length 1 forecasts (#400). + # fabletools 0.4.2 Minor patch to build package with latest R version as requested by CRAN. diff --git a/R/plot.R b/R/plot.R index 9cee122e..0bb19f35 100644 --- a/R/plot.R +++ b/R/plot.R @@ -349,7 +349,7 @@ build_fbl_layer <- function(object, data = NULL, level = c(80, 95), out[[length(out) + 1L]] <- ggdist::geom_lineribbon(without(intvl_mapping, "colour_ramp"), data = dist_qi_frame(object[single_row[["FALSE"]],], level), ..., inherit.aes = FALSE, key_glyph = draw_key_ribbon) } if(length(single_row[["TRUE"]]) > 0) { - out[[length(out) + 1L]] <- ggdist::stat_interval(intvl_mapping, data = dist_qi_frame(object[single_row[["TRUE"]],], level), ..., inherit.aes = FALSE, key_glyph = draw_key_ribbon) + out[[length(out) + 1L]] <- ggdist::geom_interval(intvl_mapping, data = dist_qi_frame(object[single_row[["TRUE"]],], level), orientation = "vertical", ..., inherit.aes = FALSE, key_glyph = draw_key_ribbon) } out[[length(out) + 1L]] <- ggplot2::labs(fill = col_nm) } else { @@ -357,7 +357,7 @@ build_fbl_layer <- function(object, data = NULL, level = c(80, 95), out[[length(out) + 1L]] <- ggdist::geom_lineribbon(without(intvl_mapping, "colour_ramp"), data = dist_qi_frame(object[single_row[["FALSE"]],], level), fill = colour, ..., inherit.aes = FALSE, key_glyph = draw_key_ribbon) } if(length(single_row[["TRUE"]]) > 0) { - out[[length(out) + 1L]] <- ggdist::stat_interval(intvl_mapping, data = dist_qi_frame(object[single_row[["TRUE"]],], level), colour = colour, ..., inherit.aes = FALSE, key_glyph = draw_key_ribbon) + out[[length(out) + 1L]] <- ggdist::geom_interval(intvl_mapping, data = dist_qi_frame(object[single_row[["TRUE"]],], level), colour = colour, orientation = "vertical", ..., inherit.aes = FALSE, key_glyph = draw_key_ribbon) } }