大家如果经常绘制箱线图,还会接触到position_jitterdodge()函数,可实现分组并排后再添加随机抖动变换。语法结构如下: position_jitterdodge( jitter.width = NULL, jitter.height = 0, dodge.width = 0.75, seed = NA) 各个参数意义结合上述的position_dodge和position_jitter都可以猜到。 p42 <- ggplot(ToothGrowt...
这里是所有的点,分开使用position_jitterdodge()和美学填充。 代码语言:javascript 复制 ggplot()+geom_point(data=d,aes(x=x,y=y,fill=color.var),position=position_jitterdodge(dodge.width=dw),size=3,alpha=1,shape=21,color='darkgray')+facet_wrap(~facet.var)+scale_fill_manual(values=c('lightblu...
geom_jitter(data=df1,aes(x=group,y=y,color=x), position = position_jitterdodge(0.2)) 1. 2. 3. 4. 5. 6. 7. 8. image.png
position_dodge()的图应该更常见,dodge有“躲开”的意思,理解起来就是每个bar不要重叠,排排站就好。 position_jitter(),jitter是“抖动、扰动”的意思,应用场景可以是散点图中有点重叠,用position=jitter可以为每个点增加少量的随机噪声,这样点就不会重叠了。position_jitter()只有三个参数, position...
position="fill" position = "dodge" places overlapping objects directly beside one another. This makes it easier to compare individual values. position="dodge" geom_point作图时注意overplotting问题 position="jitter" R语言绘图 更多精彩内容,就在简书APP ...
在p1中,点不仅抖动,而且还被factor(wt)闪避。如果只需要抖动,请在position_jitterdodge中设置dodge....
"B","A","A","A","B","B","B"),y=c(1,1,1,4,5,6,1,2,3,4,5,6),group=c("G1","G1","G1","G1","G1","G1","G2","G2","G2","G2","G2","G2"))library(ggplot2)ggplot()+geom_jitter(data=df1,aes(x=group,y=y,color=x),position=position_jitterdodge(0.2...