-
Notifications
You must be signed in to change notification settings - Fork 2.1k
timezone parameter for scale_x_datetime has no effect #4007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
seems timezone not applied when the date_labels are a waiver ? ggplot(plotdata) +
geom_point(mapping=aes(x=t_stamp, y=value)) +
scale_x_datetime(date_labels= "%H:%M",
timezone = "US/Eastern")
ggplot(plotdata) +
geom_point(mapping=aes(x=t_stamp, y=value)) +
scale_x_continuous(trans = time_trans(tz = "US/Eastern")) |
Thanks, it actually processed differently depending on whether Lines 285 to 290 in f802c5e
But, even if it's Line 336 in f802c5e
However, library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
x <- c(
"2019-08-17T06:00:00",
"2019-08-17T07:00:00",
"2019-08-17T08:00:00"
)
x <- force_tz(ymd_hms(x), tzone = "US/Mountain")
# all returns the same results
t1 <- scales::time_trans("US/Mountain")
t1$transform(x)
#> [1] 1566043200 1566046800 1566050400
t1$format(t1$breaks(range(x)))
#> [1] "06:00" "06:30" "07:00" "07:30" "08:00"
t2 <- scales::time_trans("US/Eastern")
t2$transform(x)
#> [1] 1566043200 1566046800 1566050400
t2$format(t2$breaks(range(x)))
#> [1] "06:00" "06:30" "07:00" "07:30" "08:00" Created on 2020-05-19 by the reprex package (v0.3.0) |
Aha, but look at this, these are different: > t1$inverse(t1$transform(x))
[1] "2019-08-17 06:00:00 MDT" "2019-08-17 07:00:00 MDT" "2019-08-17 08:00:00 MDT"
> t2$inverse(t2$transform(x))
[1] "2019-08-17 08:00:00 EDT" "2019-08-17 09:00:00 EDT" "2019-08-17 10:00:00 EDT" |
Ok, so, I think to summarize: I believe the intention is that when you pass the Can anyone confirm if my above interpretation is correct? If so, any thoughts as to whether this is a |
This is a bug in ggplot2 |
Just leaving some comments for whoever ends up fixing this: The issue is that the trans object is never constructed with the given timezone. The code pointed to by @yutannihilation is only for fetching a timezone from the data if none is given. |
I am trying to use the
timezone
parameter toscale_x_datetime
to control how the tick labels are displayed, but I can't get it to work. Changing the timezone does not seem to make a difference to plot output. This probably applies equally toscale_y_datetime
. Potentially I am not using the correct syntax and the documentation could be expanded.The text was updated successfully, but these errors were encountered: