First of all I have to say that I read many threads about heatmap and ggplot2 here in stackoverflow and elsewhere. But my problem isn't solved yet.
I have got the following dataset:
Var1 Var2 value
1 -197.5 -197.5 0
2 -192.5 -197.5 0
3 -187.5 -197.5 0
4 -182.5 -197.5 0
5 -177.5 -197.5 0
6 -172.5 -197.5 0
.....
The value should be the colour, and a legend on the right side would be nice.
library(ggplot2)
ggheatmap <- ggplot(data = dat.plot, aes(x=Var1, y=Var2, fill=value)) +
geom_raster()+
scale_fill_gradientn(colours=rainbow(100))+
theme(axis.text.x = element_text(angle = 0))+
coord_fixed()
print(ggheatmap)
The result is:
I would like to have a "normal" rainbow scale from red=high over orange, yellow, green, light blue, dark blue=low without giving fixed discrete colours as one can do it, e.g. with scale_fill_gradient2. I wonder why "rainbow" starts with red=high end ends with some other red...
The other question: How can I add something to "smooth" the heatmap so that one doesn't see the "edges" everywhere?
rainbow
. See more here climate-lab-book.ac.uk/2014/end-of-the-rainbow & this video youtube.com/watch?v=xAoljeRJ3lU – Tung