zoukankan      html  css  js  c++  java
  • annotate(ggplot2)

    ggplot2中的annotate可以在已有图形基础上,添加任意几何对象(如rect,pointrange,text等)

    ggplot(ct1, aes(x=pos, group=Feature, weight=weight))  +
            scale_x_continuous(minor_breaks = seq(0, 5, 1)) + 
            ggtitle("Distribution on mRNA") +
            theme(axis.ticks = element_blank(), axis.text.x = element_blank()) + 
            xlab("") + 
            ylab("Frequency") +
            geom_density(adjust=adjust,aes(fill=factor(Feature),colour=factor(Feature)),alpha=0.2) +
            annotate("text", x = sum(x1[1:2])/2, y = -0.2, label = "5'UTR") +
            annotate("text", x = sum(x1[2:3])/2, y = -0.2, label = "CDS") +
            annotate("text", x = x1[1]/2, y = -0.2, label = "Promoter (1kb)") +
            annotate("text", x = sum(x1[4:5])/2, y = -0.2, label = "Tail (1kb)") +
            annotate("text", x = sum(x1[3:4])/2, y = -0.2, label = "3'UTR")  + 
            geom_vline(xintercept=x1[1:4], linetype="dotted") + 
            annotate("rect", xmin = x1[1], xmax = x1[2], ymin = -0.12, ymax = -0.08, alpha = .99, colour = "black")+
            annotate("rect", xmin = x1[3], xmax = x1[4], ymin = -0.12, ymax = -0.08, alpha = .99, colour = "black")+
            annotate("rect", xmin = x1[2], xmax = x1[3], ymin = -0.16, ymax = -0.04, alpha = .2, colour = "black") +
            xlim(0,1) +
            theme(legend.position="bottom")

    上图最底层的长方形就是用annotate制作出来的(代码来自于Guitar包)

  • 相关阅读:
    在eclipse中运行正常的java项目放到tomcat中报错的解决办法
    xml和json之间的转换
    读取文件工具类
    java解压文件
    常用语句
    形容词&&人称词
    称呼
    单词-数字使用
    单词-数字:十位20-29
    单词-数字:十位11-19
  • 原文地址:https://www.cnblogs.com/zhengzh/p/9769111.html
Copyright © 2011-2022 走看看