Some sample data to work with.
df<-data.frame(nam=rep(c("A","B","C","D","E"),times=3),
val=runif(15,0,1),type=rep(c("TypA","TypB","TypC"),each=5))
df<-rbind(df,df,df)
df$num.lev<-rep(c(10,20,30),each=15)
To change appearance of gridlines panel.grid.major
and panel.grid.minor
can be used inside theme()
. With panel.margin=
you can achieve that all facets are plotted close together.
library(ggplot2)
library(grid)
ggplot(df,aes(val,nam))+geom_point(size=3,colour="blue")+facet_grid(num.lev~type)+
scale_x_continuous(breaks=c(0,0.2,0.4,0.6,0.8))+
theme(panel.margin=unit(0,"cm"),
panel.border=element_rect(colour="black",fill=NA,size=1.2),
strip.background=element_rect(colour="black",size=1.2),
panel.grid.major.x=element_blank(),
panel.grid.minor.x=element_blank(),
panel.grid.major.y=element_line(size=1.5,colour="grey88"),
panel.background=element_rect(fill="white"))
