【问题标题】:making polar heat maps in R在 R 中制作极地热图
【发布时间】:2013-02-18 23:03:40
【问题描述】:

您好,我有一组数据(.csv 文件),其中包含距离方向和频率信息,格式为...

      30   60   90   120   150   ...
100  131   12   22   201    66
200   45   83  351   180   210
300   99  121   33     3   306
...

我有一些使用 R 的经验,但无法将一些图表放在一起。

我想使用上面的数据制作一个极坐标图。 “标题”(行名)跨越前 30、60、90 等,范围在第一列(100、200、300 等)下方,强度是距离方向组合的值,例如 100m @ 30deg = 131 个观察值。

非常感谢任何帮助。

【问题讨论】:

    标签: r heatmap polar-coordinates


    【解决方案1】:

    我会以长格式获取您的数据,将行名作为一列,然后使用 ggplot2coord_polar

     library(reshape2) 
     library(ggplot2)
     # add rownames a column 'length'
      DT$length <- rownames(DT)
     # make into long format (the value column will be the intensities
      dtlong <- melt(DT)
     # convert from factor column `X30` etc to numeric showing angle
      dtlong$angle <- as.numeric(gsub(dtlong$variable,pattern = 'X',replacement=''))
    # use ggplot with coord_polar to make the plot
    ggplot(dtlong, aes(x=length,y=angle, size = value)) + 
     geom_point() + 
     coord_polar(theta = 'y')
    

    【讨论】:

      猜你喜欢
      • 2016-07-30
      • 2011-12-06
      • 2020-07-12
      • 2020-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-03
      • 1970-01-01
      相关资源
      最近更新 更多