diff --git a/R/plot.R b/R/plot.R index f4734d220..78c3496e1 100644 --- a/R/plot.R +++ b/R/plot.R @@ -744,13 +744,14 @@ plot_predictions <- function(data = NULL, select_median <- (forecasts$range %in% 0 & forecasts$boundary == "lower") median <- forecasts[select_median] - plot <- plot + - ggplot2::geom_line(data = median, - mapping = ggplot2::aes(y = prediction, colour = "median"), - lwd = 0.4) + if (nrow(median) > 0) { + plot <- plot + + ggplot2::geom_line(data = median, + mapping = ggplot2::aes(y = prediction, colour = "median"), + lwd = 0.4) + } } - # facet if specified by the user if (!is.null(facet_formula)) { if (facet_wrap_or_grid == "facet_wrap") {