I'm tring to plot Time as hh:min
or hh:min:ss
. But as I'm using chron package (it restores time values as a fraction of a day), ggplot don't know how to automatically pick scale for object of type times, so it uses continuous to plot the data. Some sample of the data:
> x$Time
[1] 00:00:00 00:15:00 00:30:00 00:45:00 01:00:00 01:15:00 01:30:00 01:45:00 02:00:00
[10] 02:15:00 02:30:00 02:45:00 03:00:00 03:15:00 03:30:00 03:45:00 04:00:00 04:15:00
> x$Total
[1] 1 4 0 0 4 0 0 0 0 0 0 0 0 0 0 0
[17] 0 0 0 0 2 0 0 0 0 0 0 0 2 0 7 9
[33] 27 87 143 251 1263 1797 2074 2171 16 2542 2924 3194 3185 3274 3282 3362
ggplot(aes(x = x$Hora, y = x$Sum_C.Total), data = x) + geom_point()
This gives a graph where Y axis works, but X axis are values from 0 to 1 (as all my time data are from 00:00:00
to 24:00:00
). How can I convert this fraction of a day in time values in order that ggplot can plot it as hh:mm:ss
or hh:mm
?
PS: I tried this solution (plot chron times as hours from origin) but it doesn't allow me to use the "%02d:00"
format.