zoukankan      html  css  js  c++  java
  • R语言与医学统计图形-【17】ggplot2几何对象之热图

    ggplot2绘图系统——heatmap、geom_rect

    这里不介绍更常见的pheatmap包。

    1.heatmap函数

    基础包。

    data=as.matrix(mtcars)
    #接受矩阵
    heatmap(data)
    heatmap(data,scale = 'column')
    

    image.png

    heatmap(data,scale = 'column',
            col=terrain.colors(256),
            Colv = NA,
            Rowv = NA)
    

    image.png

    2.geom_tile

    ggplot2
    中,热图可看作若干个小矩形组成。其几何对象就是rect(矩形)或tile(瓦片),两者效果相同。

    mydata <- data.frame(year=2000:2015,lung=runif(16),
                         liver=runif(16),bone=runif(16),
                         luk=runif(16),eso=runif(16),gas=runif(16),
                         eye=runif(16),brain=runif(16),pan=runif(16),
                         kidney=runif(16),breast=runif(16))
    mydata2 <- reshape(mydata,varying = list(names(mydata)[-1]),
                       timevar = 'cancer',direction = 'long',
                       times = names(mydata)[-1])
    ggplot(mydata2,aes(x=year,y=cancer))+
      geom_tile(aes(fill=lung))+ #瓦片图
      coord_polar(theta = 'y',start = 0.25)+ #极坐标转换
      scale_fill_gradient(low = 'white',high = 'red')+
      guides(fill=guide_colorbar(title = '肿瘤发病率'))
    

    image.png

  • 相关阅读:
    jenkins代码自动部署
    jenkins安装
    git图形管理工具
    gitlab自动备份恢复与卸载
    linux下获取外网IP
    网站安全webshell扫描
    jQuery动画效果实现
    form表单中的enctype属性什么意思?
    你那么努力又怎么样!
    话语
  • 原文地址:https://www.cnblogs.com/jessepeng/p/12307754.html
Copyright © 2011-2022 走看看