0

我有一些数据想转换成热图,就像这篇文章中的 MSFT 一样最未充分利用的数据可视化

Date    temp  week    wday    year
2013-01-02  -21  1   3   2013
2013-01-03  -22  1   4   2013
2013-01-04  -23  1   5   2013
2013-01-07  0  2   1   2013
2013-01-08  25  2   2   2013
2013-01-09  26  2   3   2013
2013-01-10  27  2   4   2013
2013-01-11  28  2   5   2013
2013-01-14  29  3   1   2013

hmap <- read.csv("heatmaptest.txt", as.is=TRUE)
hmap <- transform(hmap,
  week = as.POSIXlt(Date)$yday %/% 7 + 1,
  wday = as.POSIXlt(Date)$wday,
  year = as.POSIXlt(Date)$year + 1900)

library(ggplot2)
ggplot(hmap, aes(week, wday, fill = temp)) + 
  geom_tile(colour = "white") + 
  scale_fill_gradientn(colours = c("#D61818","#FFAE63","#FFFFBD","#B5E384")) + 
  facet_wrap(~ year, ncol = 1)

我如何保证,在这种情况下,热图上的绿色将从数字 >=x 开始,例如 >=25,

即通过4个十六进制代码立即而不是逐渐改变

4

0 回答 0