Closed mitchelloharawild closed 3 years ago
Seems that there's no the argument of n
in scale_x_date*()
in {ggplot2}?
library(tsibble)
library(ggplot2)
pedestrian %>%
dplyr::filter(Sensor == "Southern Cross Station") %>%
ggplot(aes(x = Date_Time, y = Count)) +
geom_line() +
scale_x_datetime(n = 3)
Created on 2020-08-26 by the reprex package (v0.3.0)
I think it can get passed in from somewhere, but I forget where (possibly by changing n_default
?). I use it internally for changing the number of breaks that are automatically selected.
Can you provide a scale_x_date()
example that uses n
?
Does the new commit resolve your issue?
tsibble::scale_x_yearmonth()$trans$breaks
#> function(x) {
#> yearmonth(scales::breaks_pretty(n)(as_date(x)))
#> }
#> <bytecode: 0x7fdeb2e89cd8>
#> <environment: 0x7fdeb2e86288>
Created on 2020-09-19 by the reprex package (v0.3.0)
What's the issue with also accepting n
as a parameter?
ggplot2::scale_x_date()$trans$breaks
#> function (x, n = n_default)
#> {
#> breaks <- pretty(x, n, ...)
#> names(breaks) <- attr(breaks, "labels")
#> breaks
#> }
#> <bytecode: 0x55f35ec2c068>
#> <environment: 0x55f35ec263b0>
Created on 2020-09-21 by the reprex package (v0.3.0)
The {scales} package doesn’t provide that kind of api.
Cheers, Earo
On 21 Sep 2020, at 11:01, mitchelloharawild wrote:
What's the issue with also accepting
n
as a parameter?ggplot2::scale_x_date()$trans$breaks #> function (x, n = n_default) #> { #> breaks <- pretty(x, n, ...) #> names(breaks) <- attr(breaks, "labels") #> breaks #> } #> <bytecode: 0x55f35ec2c068> #> <environment: 0x55f35ec263b0>
Created on 2020-09-21 by the reprex package (v0.3.0)
-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/tidyverts/tsibble/issues/216#issuecomment-695847355
Most (all?) ggplot2 scale breaks allow
n
to determine the number of breaksScales from {tsibble} do not allow this option to
pretty()
Created on 2020-08-25 by the reprex package (v0.3.0)