Skip to content

Commit 9262f3d

Browse files
committed
reimplement tidyverse#3591
1 parent 15bde2f commit 9262f3d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

R/scale-.R

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,18 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
744744
breaks <- self$trans$minor_breaks(b, limits, n)
745745
}
746746
} else if (is.function(self$minor_breaks)) {
747-
# Find breaks in data space, and convert to numeric
748-
breaks <- self$minor_breaks(self$trans$inverse(limits))
747+
# Using `fetch_ggproto` here to avoid auto-wrapping the user-supplied
748+
# breaks function as a ggproto method.
749+
break_fun <- fetch_ggproto(self, "minor_breaks")
750+
arg_names <- fn_fmls_names(break_fun)
751+
752+
# Find breaks in data space
753+
if (length(arg_names) == 1L) {
754+
breaks <- break_fun(self$trans$inverse(limits))
755+
} else {
756+
breaks <- break_fun(self$trans$inverse(limits), self$trans$inverse(b))
757+
}
758+
# Convert breaks to numeric
749759
breaks <- self$trans$transform(breaks)
750760
} else {
751761
breaks <- self$trans$transform(self$minor_breaks)

0 commit comments

Comments
 (0)