R: heatmap. 2 change the color key

I have a question about the package gplots. I want to use a function heatmap.2, and therefore I want to change my symmetric point in the color key from 0 to 1. Usually, when symkey=TRUEyou use it col=redgreen(), a color panel is created in which the colors are managed as follows:

red = -2 to -0.5
black=-0.5 to 0.5
green= 0.5 to 2

Now I want to create a color panel as follows:

red= -1 to 0.8
black= 0.8 to 1.2
green= 1.2 to 3

Is something like this possible?

Thank!

+5
source share
1 answer

If you look at the heatmap.2 help file , it looks like you want an argument breaks. From the help file:

breaks () , x , , , min (x) ()

, breaks, . :.

library(gplots)

# make up a bunch of random data from -1, -.9, -.8, ..., 2.9, 3
# 10x10
x = matrix(sample(seq(-1,3,by=.1),100,replace=TRUE),ncol=10)

# plot. We want -1 to 0.8 being red, 0.8 to 1.2 being black, 1.2 to 3 being green.
heatmap.2(x, col=redgreen, breaks=c(-1,0.8,1.2,3))

breaks=c(-1,0.8,1.2,3), .

+9

All Articles