ggplot2
ggplot2 copied to clipboard
`n.breaks` only supported when `breaks = waiver()`
This is a minor gripe, but in scale_*_continuous(n.breaks = 20), the n.breaks only kicks in when breaks = waiver() (the default).
The ask here is to also have n.breaks apply when giving a custom function(x, n) {...} so that one can flexibly combine breaks functions with the desired number of breaks.
Many scales::breaks_*() function factories have n as an argument in the constructor, so it isn't a direct problem for this function family.
However, it'd be swell if this would work for user-defined functions too.
As an example, I'd like the following two plots to be identical:
library(ggplot2)
p <- ggplot(mpg, aes(displ, hwy)) +
geom_point()
p + scale_y_continuous(
breaks = scales::breaks_extended(), # resulting function has `n` as argument
n.breaks = 20
)

p + scale_y_continuous(
breaks = scales::breaks_extended(20),
)

Created on 2024-07-03 with reprex v2.1.0