From 900f044ee37392ef01298d657a9787db9f4cd28c Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 31 May 2024 11:24:23 +0200 Subject: [PATCH 1/3] sort continuous limits --- R/scale-.R | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/R/scale-.R b/R/scale-.R index 9eaa153590..e5a924c4fa 100644 --- a/R/scale-.R +++ b/R/scale-.R @@ -127,11 +127,6 @@ continuous_scale <- function(aesthetics, scale_name = deprecated(), palette, nam guide <- "none" } - transform <- as.transform(transform) - if (!is.null(limits) && !is.function(limits)) { - limits <- transform$transform(limits) - } - # Convert formula to function if appropriate limits <- allow_lambda(limits) breaks <- allow_lambda(breaks) @@ -140,6 +135,14 @@ continuous_scale <- function(aesthetics, scale_name = deprecated(), palette, nam oob <- allow_lambda(oob) minor_breaks <- allow_lambda(minor_breaks) + transform <- as.transform(transform) + if (!is.null(limits) && !is.function(limits)) { + limits <- transform$transform(limits) + if (!anyNA(limits)) { + limits <- sort(limits) + } + } + ggproto(NULL, super, call = call, From 3a944ecdf69fc96e4aafb3e9e800fea7be21016e Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 31 May 2024 11:24:40 +0200 Subject: [PATCH 2/3] viewscale has sorted limits --- R/scale-view.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/scale-view.R b/R/scale-view.R index de78ebffb6..9679001868 100644 --- a/R/scale-view.R +++ b/R/scale-view.R @@ -35,7 +35,7 @@ view_scale_primary <- function(scale, limits = scale$get_limits(), name = scale$name, scale_is_discrete = scale$is_discrete(), limits = limits, - continuous_range = continuous_range, + continuous_range = continuous_scale_sorted, breaks = breaks, minor_breaks = minor_breaks ) From 2c631f4dd649f85ec2d07871c6f3a3b549758db8 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 31 May 2024 11:29:07 +0200 Subject: [PATCH 3/3] add news bullet --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index de3e87cee3..877e7e20be 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # ggplot2 (development version) +* `continuous_scale()` passes sorted limits to scale (@teunbrand, #5918) * The `arrow.fill` parameter is now applied to more line-based functions: `geom_path()`, `geom_line()`, `geom_step()` `geom_function()`, line geometries in `geom_sf()` and `element_line()`.