科研绘图

2023-10-14 | 箱型图

2023-10-13  本文已影响0人  千万别加香菜

1.普通箱型图

geom_boxplot绘制箱型图,alpha设置透明度

library(ggplot2)
library(ggthemes)
library(RColorBrewer)
a=read.table("1-ROH.txt",header=T)
p = ggplot(a,aes(x=Breed,y=length,fill=Breed))+  
  geom_boxplot(alpha = 0.5)+
  theme_few()

p + labs(x="Breed",y = "Length of ROH per individual(Mb)")+ 
   theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1)) +
   theme(legend.position = 'none')
image.png

2.加上散点

geom_jitter函数设置抖动点,加在箱型图上

library(ggplot2)
library(ggthemes)
a=read.table("gene_cnv.txt",header=T)
ggplot(a,aes(x=POP,y=TMEM26,fill=POP))+  
  geom_boxplot(outlier.shape = NA)+
  geom_jitter(width=0.2, alpha=0.5) +
  labs(x="TMEM26",y = "Normalized Copy Number")+ 
  theme_classic() + 
  theme(panel.border=element_rect(fill=NA,color="black", 
                                  linewidth=0.5, linetype ="solid"))+
  theme(legend.position="none")
image.png
上一篇下一篇

猜你喜欢

热点阅读