Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggplot2 (development version)

* Fixed bug where binned scales wouldn't simultaneously accept transformations
and function-limits (@teunbrand, #6144).
* Fixed bug where the `ggplot2::`-prefix did not work with `stage()`
(@teunbrand, #6104).
* New `get_labs()` function for retrieving completed plot labels
Expand Down
2 changes: 1 addition & 1 deletion R/scale-.R
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ binned_scale <- function(aesthetics, scale_name = deprecated(), palette, name =
}

transform <- as.transform(transform)
if (!is.null(limits)) {
if (!is.null(limits) && !is.function(limits)) {
limits <- transform$transform(limits)
}

Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-scale-binned.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ test_that("binned limits should not compute out-of-bounds breaks", {
))
})

test_that("binned scales can use limits and transformations simultaneously (#6144)", {
s <- scale_x_binned(
limits = function(x) x + 1,
trans = transform_log10()
)
s$train(c(0, 1)) # c(1, 10) in untransformed space
out <- s$get_limits()
expect_equal(s$get_limits(), log10(c(2, 11)))
})

test_that("binned scales can use NAs in limits", {
scale <- scale_x_binned(limits = c(NA, 10))
scale$train(c(-20, 20))
Expand Down
Loading