Skip to content

Commit

Permalink
reimplement tidyverse#3591
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Dec 7, 2023
1 parent 15bde2f commit 9262f3d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions R/scale-.R
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,18 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
breaks <- self$trans$minor_breaks(b, limits, n)
}
} else if (is.function(self$minor_breaks)) {
# Find breaks in data space, and convert to numeric
breaks <- self$minor_breaks(self$trans$inverse(limits))
# Using `fetch_ggproto` here to avoid auto-wrapping the user-supplied
# breaks function as a ggproto method.
break_fun <- fetch_ggproto(self, "minor_breaks")
arg_names <- fn_fmls_names(break_fun)

# Find breaks in data space
if (length(arg_names) == 1L) {
breaks <- break_fun(self$trans$inverse(limits))
} else {
breaks <- break_fun(self$trans$inverse(limits), self$trans$inverse(b))
}
# Convert breaks to numeric
breaks <- self$trans$transform(breaks)
} else {
breaks <- self$trans$transform(self$minor_breaks)
Expand Down

0 comments on commit 9262f3d

Please sign in to comment.