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包)

  • 相关阅读:
    Zabbix 最新安装视频
    Centos大文件切割和合并
    Docker 基础
    Docker的安装及加速
    mysql/MariaDB 搭建后创建密码及开启远程
    zabbix 添加 ROS 软路由监控 WinBox设置
    解决zabbix3.4X图形页面中文乱码
    Redis 4.0+安装及配置
    Zabbix3.4服务器的搭建--CentOS7
    CentOS 7 Nginx+PHP环境搭建!
  • 原文地址:https://www.cnblogs.com/zhengzh/p/9769111.html
Copyright © 2011-2022 走看看