[R] breaks argument in heatmap.2 doesn't do what it should I think

Witold E Wolski wewolski at gmail.com
Tue Aug 6 13:27:19 CEST 2013


I do set the breaks parameter in heatmap.2
I would expect that the color.key and the histogram (the thing in the
top left of the plot) are aligned.
Just that everyone can reproduce the problem:


mypalette<-brewer.pal(11,"RdYlBu")
ddd <- rnorm(400,0,0.1)
mdd <- matrix(ddd,ncol=50)
hm <- heatmap.2(mdd,col=mypalette,scale="row") #this is used to
produce the breaks, (and here it works fine)

mdd <- t(scale(t(mdd)))
heatmap.2(mdd,col=mypalette,scale="none",breaks=hm$breaks)

# take a look and you will see that the colors are not aligned with the breaks
although the documentation states
breaks: (optional) Either a numeric vector indicating the splitting
          points for binning ‘x’ into colors, or a integer number of
          break points to be used, in which case the break points will
          be spaced equally between ‘min(x)’ and ‘max(x)’.



-- 
Witold Eryk Wolski



More information about the R-help mailing list