diff --git a/NEWS.md b/NEWS.md index b2aba51e19..9e0997dc85 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,7 @@ # ggplot2 (development version) -* (internal) The ViewScale class has a `freeze()` method to permit copying - trained position scales (#3441). +* (internal) The ViewScale class has a `make_fixed_copy()` method to permit + copying trained position scales (#3441). * New parameters for `geom_label()` (@teunbrand and @steveharoz, #5365): * The `linewidth` aesthetic is now applied and replaces the `label.size` argument. diff --git a/R/scale-view.R b/R/scale-view.R index 576b890947..a926084cd8 100644 --- a/R/scale-view.R +++ b/R/scale-view.R @@ -151,7 +151,7 @@ ViewScale <- ggproto("ViewScale", NULL, self$rescale(b) }, - freeze = function(self) { + make_fixed_copy = function(self) { breaks <- self$get_breaks() minor <- self$get_breaks_minor() transform <- self$scale$get_transformation() diff --git a/tests/testthat/test-scales.R b/tests/testthat/test-scales.R index d2f7ae6924..5f14a7189c 100644 --- a/tests/testthat/test-scales.R +++ b/tests/testthat/test-scales.R @@ -748,7 +748,7 @@ test_that("discrete scales work with NAs in arbitrary positions", { }) -test_that("ViewScales can be frozen", { +test_that("ViewScales can make fixed copies", { p1 <- ggplot(mpg, aes(drv, displ)) + geom_boxplot() + @@ -761,8 +761,8 @@ test_that("ViewScales can be frozen", { p2 <- ggplot(mpg, aes(drv, cyl)) + geom_violin() + annotate("point", x = 15, y = 100) + - b1$x$freeze() + - b1$y$freeze() + b1$x$make_fixed_copy() + + b1$y$make_fixed_copy() b2 <- ggplot_build(p2) # Breaks and labels should respect p1's limits