【发布时间】:2020-05-22 17:58:13
【问题描述】:
library(ggplot2)
library(reshape2)
HAVE = data.frame(VARS = c("cat", "dog", "fox", "rabbit"),
"a" = c(1,2,3,4),
"b" = c(2,3,1,4),
"c" = c(3,1,2,4))
HAVE1 = melt(HAVE, id.vars="VARS")
ggplot(HAVE1, aes(VARS, variable, fill= value)) +
geom_tile() +
scale_fill_gradient(low="white", high="blue")
我希望生成从黄色(低值)到蓝色(高值)的颜色图。我希望顶部的列是“变量”,而 yticks 是 VARS,例如:请注意这只是一个示例!!
【问题讨论】: