Open davidhodge931 opened 5 months ago
It'd be useful to have a function to split a scale into breaks of equal size from the limits.
I thought maybe it might like it scales::breaks_equal(n = NULL, ....)
scales::breaks_equal(n = NULL, ....)
Below is the output that it would generate in breaks as a demo for different n's for a example limits of c(0, 10), but rounded sensibly.
x1 <- 0 x2 <- 10 n <- 2 seq(from = x1, to = x2, by = (x2 - x1) / (n - 1)) #> [1] 0 10
n <- 3 seq(from = x1, to = x2, by = (x2 - x1) / (n - 1)) #> [1] 0 5 10
n <- 4 seq(from = x1, to = x2, by = (x2 - x1) / (n - 1)) #> [1] 0.000000 3.333333 6.666667 10.000000
n <- 5 seq(from = x1, to = x2, by = (x2 - x1) / (n - 1)) #> [1] 0.0 2.5 5.0 7.5 10.0
n <- 6 seq(from = x1, to = x2, by = (x2 - x1) / (n - 1)) #> [1] 0 2 4 6 8 10
Created on 2024-06-15 with reprex v2.1.0
Also, be great if this could work with Date's etc
Are you think of the seq(length.out) argument, or is it somewhat more complex than this?
seq(length.out)
It'd be useful to have a function to split a scale into breaks of equal size from the limits.
I thought maybe it might like it
scales::breaks_equal(n = NULL, ....)
Below is the output that it would generate in breaks as a demo for different n's for a example limits of c(0, 10), but rounded sensibly.
Created on 2024-06-15 with reprex v2.1.0