You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This request is prompted by an issue in ggplot2::scale_*_time() described here. Essentially, calling scale_*_time() with the sec.axis argument set throws an error because scales::rescale() doesn't have hms or difftime methods:
library(hms)
library(ggplot2)
x_datetime<- as.POSIXct(paste0("2023-01-01 ", 0:23, ":00:00"))
x_time<- as_hms(x_datetime)
y<- sin(pi*0:23/6)
dat<-data.frame(x_datetime, x_time, y)
ggplot(dat, aes(x_time, y)) +
geom_line() +
scale_x_time(sec.axis= sec_axis(trans=identity))
#> Error in UseMethod("rescale"): no applicable method for 'rescale' applied to an object of class "c('hms', 'difftime')"
This request is prompted by an issue in
ggplot2::scale_*_time()
described here. Essentially, callingscale_*_time()
with thesec.axis
argument set throws an error becausescales::rescale()
doesn't have hms or difftime methods:As @teunbrand demonstrated in the ggplot2 issue, defining a
rescale.difftime()
method would resolve the issue.The text was updated successfully, but these errors were encountered: