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 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") 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 #