美文网首页科研绘图
2023-10-14 | 箱型图

2023-10-14 | 箱型图

作者: 千万别加香菜 | 来源:发表于2023-10-13 09:27 被阅读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

    相关文章

      网友评论

        本文标题:2023-10-14 | 箱型图

        本文链接:https://www.haomeiwen.com/subject/avtabdtx.html