[R] Attempting to make a custom color spectrum to use in heatmap.2

Daniel Bernstein bernsted at reed.edu
Thu Aug 7 01:57:56 CEST 2008

Hello there! I'd just like to say in advance, "Thank you," for any help 
and/or advice.

My problem is as follows:

I have a dataset that is made up of percentages. I've assigned my 
"error" percentages a value of '-100', my "non-existent" percentages a 
value of '0', and all my other percentages are normal values that range 
from the high 60's to 100. I would like to create a heatmap that 
designates my "error" values as gray, my "non-existent" values as black, 
and I would like to to have the rest of my values, say 50 to 100, as a 
rainbow-type spectrum (like the palette "Spectral" in RColorBrewer, 
except with 50 values).

I've tried using breaks, and then implementing the breaks in my 
heatmap.2 command. The breaks work just fine. I guess what I want to 
control is the range of the:

col=(colorpanel(#, low="color1", mid="color2", high="color3"))

command. Is there any way to set more values than "low," "mid," and 
"high?" If that is possible I think it would solve my problem. I've 
looked over the documentation and searched over previous 
color/heatmap-related questions, but haven't come across anything that 
points me in the right direction.

Please let me know if any of what I said needs clarifying before you can 
give me what you feel is an appropriate response. Thanks again for your 



More information about the R-help mailing list