I like to make a ggplot theme where the default number of axis breaks is double the default. I'm not sure what setting to update. I can see from this question that ggplot calculates the breaks using labeling::extended
. From the doc I can see that the argument m
controls the number of breaks:
Usage
extended(dmin, dmax, m, Q = c(1, 5, 2, 2.5, 4, 3), only.loose = FALSE, w = c(0.25, 0.2, 0.5, 0.05))
m number of axis labels
This gets passed from scales::extended_breaks
which I can see has the default set to 5:
function (n = 5, ...)
{
n_default <- n
function(x, n = n_default) {
x <- x[is.finite(x)]
if (length(x) == 0) {
return(numeric())
}
rng <- range(x)
labeling::extended(rng[1], rng[2], n, ...)
}
}
So is there a theme setting I could change to default n to e.g. 10?
theme_more_ticks <- function(nticks = 10) {
theme_minimal() +
...?
}
I know that breaks for an individual plot can be changed in many ways (ref). However, I would like all plots I produce with this theme to have double the number of breaks they would have with the default theme.
breaks
argument in the appropriatescale_xxx_yyy
function? – Limeyscale_xxx_yyy
to every plot. – Pete900