我怎样才能dotchart在ggplot2中绘制像格子一样的点图,它有更粗的网格线和只有水平网格线(即删除垂直网格线),有点像这样:

除了使水平线更大胆以使它们更加明显.
有没有办法在ggplot2中这样做?
一些样本数据可供使用.
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)
Run Code Online (Sandbox Code Playgroud)
要更改网格线的外观panel.grid.major和panel.grid.minor里面可以使用theme().通过panel.margin=您可以实现所有方面都紧密地绘制在一起.
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"))
Run Code Online (Sandbox Code Playgroud)
