geom_boxplot 箱线图

ggplot(data=data1,mapping = aes(x=VARIANT_TYPE,y=NON_REF_GENOTYPE_CONCORDANCE))+geom_boxplot()+scale_y_continuous(expand=c(0,0),breaks = c(0,75,0.80,0.85,0.95,1.00),labels=c(0,75,0.80,0.85,0.95,1.00),limits = c(0.79,1))
 

 ggplot(data=data1,mapping = aes(x=VARIANT_TYPE,y=NON_REF_GENOTYPE_CONCORDANCE))+geom_boxplot()+scale_y_continuous(expand=c(0,0),breaks = c(0,75,0.80,0.85,0.95,1.00),labels=c(0,75,0.80,0.85,0.95,1.00),limits = c(0.79,1))+coord_fixed(ratio=100) 

#+coord_fixed(ratio=100)  调整纵/横轴显示比例。越大,y轴拉长,x轴压缩

 

ggplot(data=data1,mapping = aes(x=VARIANT_TYPE,y=NON_REF_GENOTYPE_CONCORDANCE))+geom_boxplot()+scale_y_continuous(breaks=c(0,7,0.835,0.97,1),labels=c(0,7,0.835,0.97,1))+scale_y_break(c(0.81,0.972))  # 中间空的breaks较多,删掉。给箱线图更多空间

 

 但结果也不是很好看,所以更好的方式是两个箱线图分开画。这样,尽可能的展开如

 data1_INDEL<-data1%>%filter(VARIANT_TYPE=="INDEL")

ggplot(data=data1_INDEL,mapping = aes(x=VARIANT_TYPE,y=NON_REF_GENOTYPE_CONCORDANCE))+geom_boxplot()+scale_y_continuous(breaks=c(0,7,0.835),labels=c(0,7,0.835))

 

 

 

  

posted on 2022-02-19 11:14  BioinformaticsMaster  阅读(371)  评论(0编辑  收藏  举报

导航