I've made a heatmap in R using heatmap.2
and the only thing I can't figure out is how to control the presence and labeling of tick marks on the color key. I have an example below. What I would like to do is have tick marks at the beginning and end of the color key to indicate the range of values (in this case 0-1), rather than 6 tick marks with labels at 0, 0.4 and 0.8. I'm sure there is a simple way to control this but I can't seem to find it.
library('gplots')
data <- c(0, 0.1, 0.1, 0.2, 0.2, 0.7, 0.7, 0.8, 1)
matr <- matrix(data, 3, 3)
heatmap.2(matr, trace="none", density.info="none")
EDIT:
The only fix I can find is to directly change heatmap.2
itself to accept additional arguments as this seems to be hardcoded (in my case I want to add a min and max range for the color key).
Original heatmap.2
heatmap.2 <-function (...)
{
...
lv <- pretty(breaks) # line 362
...
}
Changed to:
heatmap.2 <-function (..., xMin = NULL, xMax = NULL, ...)
{
...
if(is.null(xMin)) lv <- pretty(breaks)
else lv <- c(xMin, xMax)
...
}