From b38677eb7f025848e8ee9eb39ab3b33000f64812 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 19 Nov 2025 15:29:21 -0800 Subject: [PATCH 1/3] coerce axis vars to numeric for range (test) --- R/lim.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/lim.R b/R/lim.R index 46d9c0e4..7eb13aad 100644 --- a/R/lim.R +++ b/R/lim.R @@ -23,14 +23,14 @@ lim_args = function(settings) { } if (is.null(xlim)) { - xlim = range(c( + xlim = range(as.numeric(c( datapoints[["x"]], datapoints[["xmin"]], - datapoints[["xmax"]]), finite = TRUE) + datapoints[["xmax"]])), finite = TRUE) } if (is.null(ylim)) { - ylim = range(c( + ylim = range(as.numeric(c( datapoints[["y"]], datapoints[["ymin"]], - datapoints[["ymax"]]), finite = TRUE) + datapoints[["ymax"]])), finite = TRUE) } if (identical(type, "boxplot")) { From cb6c1569678c61f1d4e065a529a201fbc5e88922 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 19 Nov 2025 15:55:18 -0800 Subject: [PATCH 2/3] redundant to calculate limits for added layers --- R/tinyplot.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/tinyplot.R b/R/tinyplot.R index ab40ee48..72fd8b12 100644 --- a/R/tinyplot.R +++ b/R/tinyplot.R @@ -882,8 +882,9 @@ tinyplot.default = function( # # do this after computing yaxb because limits will depend on the previous calculations - lim_args(settings) - + if (!add) { + lim_args(settings) + } # ## facets: count ----- From 6a6d1bd4273d4f9a9e2259207cf6886384d6ce3c Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Wed, 19 Nov 2025 16:11:49 -0800 Subject: [PATCH 3/3] news --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 93aa1fa4..45dcb16e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -35,6 +35,9 @@ where the formatting is also better._ the functions called rather than just their names. (#504 @zeileis) - Legend labels are now correct if `by` is logical. Thanks to @TCornulier for the report. (#512 @grantmcdermott) +- Axis limits are now correctly calculated for factor (and character) variables, + by coercing to numeric first. We also avoid the redundancy of re-calculating + axis limits for secondary plot layers. (#513 @grantmcdermott) ### Documentation