Skip to content

Commit

Permalink
change freeze() to make_fixed_copy()
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Jan 28, 2025
1 parent 3592dbc commit f34e0eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion R/scale-view.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-scales.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() +
Expand All @@ -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
Expand Down

0 comments on commit f34e0eb

Please sign in to comment.