Add minor ticks to ggplot2 - janeshdev/ggplot2 GitHub Wiki

There is not a default method to create minor ticks in ggplot2. However, one can create minor ticks using geom_segment function that is inbuilt in ggplot2. I used the following code to generate graph and add minor axis.

library(ggplot2)
library(grid)

set.seed(100)
x <- seq(1992, 2002, by =2)
d1 <- data.frame(x=x, y=rnorm(length(x)))

head(d1)

ggplot(d1) + geom_line(aes(x,y)) + coord_cartesian(xlim=c(1992,2003), ylim=c(-1,1))+
# Add minor axis
    annotate(geom="segment", y=seq(-1,1,0.25), yend = seq(-1,1,0.25),
             x=1992, xend= 1992.05)

The output would look like this :

Minor ticks in ggplot2