【发布时间】:2020-07-23 15:09:29
【问题描述】:
这是我的数据集“细胞计数”:
Treatment DAPI DAPO DAPU
1 DMSO 20 30 40
2 DMSO 24 26 42
3 DMSO 23 24 39
4 EPZ 0.5uM 10 25 22
5 EPZ 0.5uM 12 24 22
6 EPZ 0.5uM 14 24 30
7 EPZ 0.5uM 20 19 32
我正在尝试创建一个小提琴散点图,x 轴上是治疗组,y 轴上是细胞计数(DAPI、DAPO、DAPU),所以我总共应该有六个小提琴图。
p1<-ggplot(cellcounts,aes(x=Treatment,y=DAPI)) +geom_violin(aes(colour="DAPI"),alpha=0.5)+ geom_jitter(data=cellcounts,shape=16,position=position_jitter(0.2),colour="blue")+ geom_boxplot(width=0.1,fill="grey")
获得带有箱线图和散点图的小提琴图shown here
我还可以为 DAPO 和 DAPU 数据添加小提琴图 shown here with
p2<-p1+geom_violin(aes(Treatment,DAPO,colour="DAPO"),alpha=0.5)
p3<-p2+geom_violin(aes(Treatment,DAPU,colour="DAPU"),alpha=0.5)
如果我现在尝试添加抖动图
p3+geom_jitter(data=cellcounts,shape=16,position=position_jitter(0.2),colour="blue")
它只为 DAPI 数据添加,因为这是 ggplot 需求 (?) 我如何也为 DAPO 和 DAPU 数据添加数据点?
我还希望 DAPI Violin 和抖动点为蓝色、DAPO 绿色和 DAPU 红色。
感谢您的宝贵时间
【问题讨论】:
标签: r ggplot2 scatter-plot boxplot violin-plot