From 4f2572f82bc01977d85189b7ba74f57574251e8c Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 22 Feb 2024 14:48:08 +0100 Subject: [PATCH 1/3] fill in missing `se` --- R/geom-smooth.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/geom-smooth.R b/R/geom-smooth.R index 0c599fdca9..45ac8c4972 100644 --- a/R/geom-smooth.R +++ b/R/geom-smooth.R @@ -123,6 +123,8 @@ geom_smooth <- function(mapping = NULL, data = NULL, GeomSmooth <- ggproto("GeomSmooth", Geom, setup_params = function(data, params) { params$flipped_aes <- has_flipped_aes(data, params, range_is_orthogonal = TRUE, ambiguous = TRUE) + params$se <- params$se %||% + all(c("ymin", "ymax") %in% names(data)) params }, From 638034ff4173270a045c09747041c608d0115f00 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 22 Feb 2024 14:57:32 +0100 Subject: [PATCH 2/3] account for flipped aesthetics --- R/geom-smooth.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/geom-smooth.R b/R/geom-smooth.R index 45ac8c4972..90137fddd0 100644 --- a/R/geom-smooth.R +++ b/R/geom-smooth.R @@ -124,7 +124,12 @@ GeomSmooth <- ggproto("GeomSmooth", Geom, setup_params = function(data, params) { params$flipped_aes <- has_flipped_aes(data, params, range_is_orthogonal = TRUE, ambiguous = TRUE) params$se <- params$se %||% - all(c("ymin", "ymax") %in% names(data)) + if (params$flipped_aes) { + all(c("xmin", "xmax") %in% names(data)) + } else { + all(c("ymin", "ymax") %in% names(data)) + } + params }, From daed6864e6a62c8ce27feedd380af8a4849294ec Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 23 Feb 2024 15:22:50 +0100 Subject: [PATCH 3/3] add news bullet --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index e6f6dca449..c5d5c249f5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,10 @@ # ggplot2 (development version) +* The default `se` parameter in layers with `geom = "smooth"` will be `TRUE` + when the data has `ymin` and `ymax` parameters and `FALSE` if these are + absent. Note that this does not affect the default of `geom_smooth()` or + `stat_smooth()` (@teunbrand, #5572). + # ggplot2 3.5.0 This is a minor release that turned out quite beefy. It is focused on