在 ggplot2 中,我想控制条形图或横线图中的变量和因子内的多个位置闪避。例如:
data = data.frame(Var=c("a","a","a","a","b","b","b","b"),
Val=c(0.5,0.4,0.1,0.0,-0.1,-0.3,-0.0,0.1),
g1=c(1,2,3,4,5,6,7,8),
g2=c(1,2,3,4,1,2,3,4),
g3=c(1,2,1,2,1,2,1,2))
q = ggplot(data,aes(Var,Val,ymin = Val-0.15,
ymax=Val+0.15,
group=g1,
colour=factor(g2),
fill=factor(g2),
linetype=factor(g3),))
q + geom_crossbar(width=0.5,fatten=2,size=0.5,position=position_dodge(width=0.51)) +
coord_flip() +
theme_bw() +
scale_fill_manual(values=c("#00000090","#00000090","#00000050","#00000050")) +
scale_colour_manual(values=c("#000000","#00000070","#000000","#00000070"))
在上面的示例中,我希望能够将较暗的条与较亮的条稍微分开,同时将每个条设置在一起。我可以实施多个位置闪避来实现这一点吗?任何帮助,将不胜感激。