如何克服ggplot2中没有抖动或透明度的重叠点

Far*_*rel 6 r overlap stripchart ggplot2

我开始使用ggplot2.我有一些小的n(大约30左右)粒度数据,有很多重叠.抖动和alpha(透明度)都不合适.相反,带有堆栈和偏移的条形图最好,但我不知道如何在ggplot2中执行此操作.你知道吗?

要查看最终结果应该单击此图形.

这是我几年前使用的脚本.

stripchart(SystData$DayTo1Syst~SystData$strain,vertical=TRUE,method="stack",pch=19,offset=.3,xlab="Strain",main="Rapidity of Systemic Disease Onset",ylab="Days post inoculation")
Run Code Online (Sandbox Code Playgroud)

Jyo*_*rya 8

你可以用position_dodge.

df <- data.frame(gp = rep(LETTERS[1:5], each =8), 
                 y = sample(1:4,40,replace=TRUE))
qplot(gp,y,data=df,order=y,position=position_dodge(width=0.5))
Run Code Online (Sandbox Code Playgroud)

替代文字http://img100.imageshack.us/img100/8760/dodgel.png


xie*_*hao 6

# your data
df <- data.frame(gp = rep(LETTERS[1:5], each =8), y = sample(1:4,40,replace=TRUE))
# calculate offsets
df <- ddply(df, .(y, gp), transform, offset = (1:length(gp)-1)/20)
qplot(gp, y, data=df) + stat_identity(aes(as.numeric(gp)+offset)) + theme_bw() 
Run Code Online (Sandbox Code Playgroud)