I plot heatmaps using the levelplot
function from the lattice
package. The values in my matrix range from -1 to 1 and I used the following scale:
cols <- colorRampPalette(c("blue", "white", "red"))(256)
A small example:
d <- 20
df <- expand.grid(x = 1:d, y = 1:d)
df$z <- runif(d*d, -1, 1)
levelplot(z ~ x * y, data = df,
col.regions = cols)
I wish to adjust the scale so that a bigger proportion of the scale is white. I assume I have to manually define where the transition starts or better yet define different "transition speeds" - a slower one when I´m closer to 0 (i.e. white), and a quicker one when I get closer to 1 or -1.
Any advice for how to do this would be greatly appreciated!