I would like to make the ticks in the following graph daily instead of every 2 days.
df1 <- structure(
list(
Timestamp = structure(
c(
You can use the scales
package. It looks like you need to use the function date_breaks
, rather than just breaks
to get proper labels:
EDIT: it appears the argument has been changed to date_breaks:
library(scales)
library(ggplot2)
ggplot(df1, aes(x = Timestamp, y = number)) +
geom_line(size=2) +
geom_point(size=5) +
scale_y_continuous(breaks = seq(0, 50, by = 2)) +
scale_x_datetime(date_breaks = "1 day")
original:
library(scales)
library(ggplot2)
ggplot(df1, aes(x = Timestamp, y = number)) +
geom_line(size=2) +
geom_point(size=5) +
scale_y_continuous(breaks = seq(0, 50, by = 2)) +
scale_x_datetime(breaks = date_breaks("1 day"))
If you want to change how the date is displayed in the label, you can use date_format
inside the scale_x_datetime
call.
Instead of using scale_x_datetime(breaks = "1 day"), try for scale_x_datetime(date_breaks = "1 day")