0

I'm using heatmap.2 to obtain a triangular heatmap (where the upper part of the matrix is deleted).

I used this code: my_data_t <- t( as.matrix(my_data) )

`cor.matrix <- cor( my_data_t, method = "spearman")`

`cor.matrix[upper.tri( cor.matrix )] <- NA`

`my.col <- c( "blue", "green", "yellow", "orange", "red" )`

`my.breaks <- c( 0, 0.2, 0.6, 0.8, 1 )`

`hm2 <- heatmap.2( cor.matrix, scale="none", Rowv=NA, Colv=NA, 
                  col=my.col, breaks=my.breaks, margins(5,5),
                  cexRow=0.5,cexCol=1.0,key=TRUE,keysize=1.5, 
                  trace="none")`

my_data was something like this: my_data <- "Taxon NO8.4 NO6.1 NO7.3 NO9.4 N09.7 a 0.1 0.05 0.01 0.2 0.06 b 0.0 0.8 0.8 0.0 0.0 c 0.7 0.0 0.0 0.0 0.1 d 0.0 0.01 0.08 0.0 0.09 e 0.0 0.0 0.0 0.0 0.0 f 0.09 0.05 0.01 0.04 0.0 g 0.07 0.7 0.0 0.01 0.08"

Now I'd like to have the color key on the right of the heatmap and I'd like tomake it bigger (as a bar on the right of the heatmap, as long as this one). Is it possile in the heatmap.2 function??

I also tried to use the legend() command, but it seems to me that it can generate only box legends, with one box for each color, so no an unique side bar, right??

  • As you might recall from yesterday, you were asked to provide a [minimal, reproducible data set](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) together with the code you have tried. The same kind request applies today. Thanks. – Henrik Oct 02 '13 at 19:03
  • I'm sorry... but I didn't find how to upload files... – Francesca de Filippis Oct 02 '13 at 20:04

1 Answers1

0

See the answer here: Moving color key in R heatmap.2 (function of gplots package)

Unfortunately, what you won't be able to do is rotate the key, which would seem like something you would want to do in this situation.

Community
  • 1
  • 1
Ian Sudbery
  • 1,708
  • 13
  • 15