Is there a function to adjust the breaks of a ggplot that is using time in the format of hh:mm:ss?

34 Views Asked by At

I have created a graph in ggplot2 that is using time on the x-axis in the format of hh:mm:ss. The graph is automatically setting the scale breaks at 00:00:00, 10:00:00, and 20:00:00, but I would like for the breaks to be 00:00:00, 06:00:00, 12:00:00, and 18:00:00. Is there a function I could use to perform this?

So far I have tried using scale_x_continuous with the help of as.POSIXct, and have managed to change the breaks but not to what I am trying to change them to.

scale_x_continuous(labels = function(x) format(as.POSIXct(x, tz = "GMT-5"), 
  "%H:%M:%S", breaks = c( 00, 06, 12, 18)))
0

There are 0 best solutions below