[R] Minor Ticks on ggplot2

Eduardo M. A. M.Mendes emammendes at gmail.com
Tue Jul 28 01:46:15 CEST 2015


Hi

Although I could find some answers on how to add minor ticks on a ggplot on stack overflow, I could not figure to how to add them to the following example:

library(ggplot2)

x <- data.frame(V1=runif(1000, -6.0, 6.0),V2=runif(1000, -6.0, 6.0));

               
g<-ggplot(x,aes(V1,V2))+geom_point(size=1.5)+theme_bw()
g<-g+scale_y_continuous(name="y(t)")+scale_x_continuous(name="x(t)")
g<-g+theme(axis.title.x = element_text(face="italic", size=20),axis.title.y = element_text(face="italic", size=20))
g<-g+theme(axis.text.x  = element_text(angle=0, vjust=0.5, size=16),axis.text.y  = element_text(angle=0, vjust=0.5, size=16))
g<-g+coord_cartesian(xlim=c(min(x[,1]),max(x[,1])), ylim=c(min(x[,2]),max(x[,2])))
print(g)

How to add gridlines (or points) to the minor ticks?

Many thanks

Ed



More information about the R-help mailing list