Skip to content

Commit 954924b

Browse files
Only call zero_range() and as.numeric() in transformed space (#5304)
* Only call `zero_range()` and `as.numeric()` in transformed space In case the `limits` in data space don't support conversion to numeric * Add comment with link to PR * NEWS bullet --------- Co-authored-by: Teun van den Brand <49372158+teunbrand@users.noreply.github.com>
1 parent 5da2d30 commit 954924b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ggplot2 (development version)
22

3+
* `ScaleContinuous$get_breaks()` now only calls `scales::zero_range()` on limits
4+
in transformed space, rather than in data space (#5304).
5+
36
* Scales throw more informative messages (@teunbrand, #4185, #4258)
47

58
* The `scale_name` argument in `continuous_scale()`, `discrete_scale()` and

R/scale-.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,9 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
691691
)
692692
}
693693

694-
if (zero_range(as.numeric(limits))) {
694+
# Compute `zero_range()` in transformed space in case `limits` in data space
695+
# don't support conversion to numeric (#5304)
696+
if (zero_range(as.numeric(self$trans$transform(limits)))) {
695697
breaks <- limits[1]
696698
} else if (is.waive(self$breaks)) {
697699
if (!is.null(self$n.breaks) && trans_support_nbreaks(self$trans)) {

0 commit comments

Comments
 (0)