Bellow solution should work:
scale_x_datetime(date_breaks = "1 day", date_labels = "%d/%m/%Y %H:%M:%S", minor_breaks = NULL) +
If plotly is not working for you then there are a few more ways that you could zoom in on your data.
- Filter at the source: you could filter in the data as it goes into ggplot.
a <- ggplot(test3a %>%
filter(localminute >= ymd(20151001),
localminute <= ymd(20151031)),
aes(x = localminute, y = meter_value)) +
- Set limits in scale_x_datetime: This has the same result as filtering the data.
scale_x_datetime(date_breaks = "1 day", date_labels = "%d/%m %Y %H:%M:%S", minor_breaks = NULL,
limits = c(ymd_hm(201510010000), ymd_hm(201510022359))) +
- Use coord_cartesian: It preserves other data that's out of range for your other layers to use, even if you're not showing it. For instance, if you had a geom_smooth layer, you'd want to use this option...
coord_cartesian(xlim = c(ymd_hm(201510010000), ymd_hm(201510011000))) +