From 4089aa9b23ecbc46df2b2d3ccd53124eaca65d2d Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 28 Jul 2026 16:29:23 -0700 Subject: [PATCH 1/3] track null x/ylim --- R/flip.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/flip.R b/R/flip.R index 66980264..c753fe0d 100644 --- a/R/flip.R +++ b/R/flip.R @@ -30,6 +30,7 @@ flip_datapoints = function(settings) { swap_elements(settings, "xlab", "ylab") swap_elements(settings, "xlabs", "ylabs") swap_elements(settings, "xlim", "ylim") + swap_elements(settings, "null_xlim", "null_ylim") swap_elements(settings, "rev_x", "rev_y") swap_elements(settings, "xmax", "ymax") swap_elements(settings, "xmin", "ymin") From 471a033e379e9858fc6c4ae87ad7787455320816 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 28 Jul 2026 16:31:52 -0700 Subject: [PATCH 2/3] test --- .../_tinysnapshot/facet_free_flip.svg | 159 ++++++++++++++++++ inst/tinytest/test-facet.R | 13 ++ 2 files changed, 172 insertions(+) create mode 100644 inst/tinytest/_tinysnapshot/facet_free_flip.svg diff --git a/inst/tinytest/_tinysnapshot/facet_free_flip.svg b/inst/tinytest/_tinysnapshot/facet_free_flip.svg new file mode 100644 index 00000000..a250535f --- /dev/null +++ b/inst/tinytest/_tinysnapshot/facet_free_flip.svg @@ -0,0 +1,159 @@ + + + + + + + + + + + + + +Free facets: flipped +mpg +carb + + + + + + + + + + + + + + + + +0 +10 +20 +30 +40 +50 + + + + + + + + +1.0 +1.5 +2.0 +2.5 +3.0 +3.5 +4.0 + +0 + + + + + + + + + + + + + + + + + +0 +10 +20 +30 +40 +50 + + + + + + + + + +1 +2 +3 +4 +5 +6 +7 +8 + +1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inst/tinytest/test-facet.R b/inst/tinytest/test-facet.R index 0c139a7c..41f256f5 100644 --- a/inst/tinytest/test-facet.R +++ b/inst/tinytest/test-facet.R @@ -572,6 +572,19 @@ f = function() { } expect_snapshot_plot(f, label = "facet_free_single_value") +# Free facets combined with flip: the fixed continuous-axis limit must follow +# the flip and be honoured, rather than the wrong axis being freed (issue #670) +f = function() { + tinyplot( + mpg ~ carb, data = mtcars, type = "p", + facet = ~am, facet.args = list(free = TRUE), + ylim = c(0, 50), + flip = TRUE, + main = "Free facets: flipped" + ) +} +expect_snapshot_plot(f, label = "facet_free_flip") + # # restore original par settings # From 3d967002291b4cbfa3451bed334991d145103ef3 Mon Sep 17 00:00:00 2001 From: Grant McDermott Date: Tue, 28 Jul 2026 16:35:25 -0700 Subject: [PATCH 3/3] news --- NEWS.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1425e1ea..aa1ccf4d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,8 +15,12 @@ where the formatting is also better._ ### Bug fixes -- Fixed bug where single-valued discrete axes would trigger invalid `par(usr)` - values when combined with free facets. (#668 @grantmcdermott) +- Fixed several bugs specific to plots with free facets (i.e., + `facet.args = list(free = TRUE)`): + - Single-valued discrete axes no longer trigger invalid `par(usr)` values. + (#668 @grantmcdermott) + - User-provided `x/ylim` overrides now work correctly with flipped plots. + (#670 @grantmcdermott) ## v0.7.0