I get the plot with HH.MM.SS format. I would like to have only 17:15 format and not 17:15:00. I have tried many options without success
Any help would be appreciated.
Thanks
Have you tried adding the layer scale_x_time() or scale_x_time()? Inside those you can define the labels,. The first works on hms objects, the second on POSIXct.
To be honest, I think it's easiest to use the latter. To do this, make sure your column time is a POSIXct class, e.g. by using a lubridate function like mdy_hms(). And if this is all one day, you could use dummy values for the month, day and year. Then add scale_x_datetime(date_labels = "%H:%M") and it will only show the hours and the minutes on your x-axis.
Yes, indeed - scale_x_time() will want you to actually supply a vector with the breaks. Which I think is a hassle and hence why I suggested creating a POSIXct object and using scale_x_datetime().
But the solution by @FJCC deals with the breaks = argument by creating a vector BREAKS which solves that. That is an excellent solution.
But keep in mind that that approach requires you to "hard code" the breaks and the labels, so if you have to make these plots for a lot of datasets with a different numbers of breaks and labels (i.e. not necessarily one day / 24 hours, or if you want different labels on different plots), it will require more coding.