我有一些数据要转换为热图,就像这篇文章Most underused data visualization中的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)
我怎么能保证,在这种情况下,热图上的绿色将从数字&gt; = x开始,例如,让我们说&gt; = 25,
即通过4个十六进制代码立即进行而不是逐步改变