I would convert columns 'date' and 'hour' to as.POSIXct
to use as x axis. In the data you show, 'hour' seems to be a character
variable (leading zeroes), and you can create a time variable like this:
d$time <- as.POSIXct(paste0(d$date, " ", d$hour, ":00:00"))
The 'time' variable can be used as x variable, and colour by date isn't really necessary (but can of course be added if you wish).
ggplot(data = d, aes(x = time, y = total_sess)) +
geom_bar(stat='identity') +
theme_bw()
When your x variable is of class as.POSIXct
, you may use scale_x_datetime
. Then it's easy to format the x axis with the breaks = date_breaks
and labels = date_format
arguments (load library(scales)
. See examples here