如何使用一个值列制作热图

时间:2016-08-11 07:22:10

标签: r heatmap

这是我的数据

df<- structure(list(name = structure(c(2L, 12L, 1L, 16L, 14L, 10L, 
9L, 5L, 15L, 4L, 8L, 13L, 7L, 6L, 3L, 11L), .Label = c("All", 
"Bab", "boro", "bra", "charli", "delta", "few", "hora", "Howe", 
"ist", "kind", "Kiss", "myr", "No", "TT", "where"), class = "factor"), 
    value = c(1.251, -1.018, -1.074, -1.137, 1.018, 1.293, 1.022, 
    -1.008, 1.022, 1.252, -1.005, 1.694, -1.068, 1.396, 1.646, 
    1.016)), .Names = c("name", "value"), class = "data.frame", row.names = c(NA, 
-16L))

我检查了之前的所有答案但是我被卡住了,我真的不知道是否有可能做到这可能非常简单,所以如果不是一个合适的问题,我已经道歉了。如果你只是给我一个提示,我会自己这样做

1 个答案:

答案 0 :(得分:1)

由于热图只是图块的变体,您可以尝试:

library(ggplot2)

ggplot(df, aes(x = name,y = 1, fill = value)) + 
  geom_tile() + 
  ylab("") 

enter image description here