Setting limits for scale_x_datetime

36 views
Skip to first unread message

Petra Jauslin

unread,
Jul 15, 2015, 10:48:25 AM7/15/15
to ggp...@googlegroups.com
I have a data set containing ID DAY TIME VALUE and CLCKT
CLCKT = clock time, produced by 

data$CLCKT <- strptime(as.character(data$TIME), format="%H:%M")

I would like to plot VALUE (y axis) against CLCKT (x axis), using

ggplot(datat, aes(CLCKT, VALUE)) + 
  geom_point() + 
  scale_x_datetime(labels = date_format("%H:%M"), name="Clock time")

This, for whatever reason, produces a plot from 22:00 to 22:00. How do I change the scale to 0:00 to 24:00?

I have tried setting limits: xlim <- as.POSIXct(c("00:00:00", "23:59:00"),format="%H:%M:%S")
which returns
[1] "2015-07-15 00:00:00 CEST" "2015-07-15 23:59:00 CEST" (today's date added, but same date for all clock times)
but when I use these limits in
scale_x_datetime(limits=xlim, labels = date_format("%H:%M"), name="Clock time")
they are simply ignored without any warning or error message.
Any help as to how to get the x axis right (from 0:00 - 24:00) would be greatly appreciated!
Reply all
Reply to author
Forward
0 new messages