Place legend at specific heatmap.2 column and row in r

171 views Asked by At

Is it possible to place a legend at a specific column & row in heatmap.2?

I.e.

> mymatrix = matrix(0,2,2)
> mymatrix
     [,1] [,2]
[1,]    0    0
[2,]    0    0

heatmap.2(mymatrix, col=bluered, Rowv = FALSE, trace="none", Colv = FALSE, main="Legend positioning")

I'd like to mark a circle, via legend, at mymatrix[2,2] in the heatmap.2

1

There are 1 answers

0
Daniel Jansen On

Solved. I have decided to make another matrix which marks the specific coordinate and note this matrix in heatmap.2

mymatrix = matrix(0,2,2) note.matrix = matrix(,2,2) note.matrix[2,2] = "|" mymatrix [,1] [,2] [1,] 0 0 [2,] 0 0

note.matrix [,1] [,2] [1,] NA NA
[2,] NA "|"

heatmap.2(mymatrix,cellnote=note.matrix,notecol="black")

Images an heatmap, where column 2 + row 2 is marked with |. If there is a more convenient way, let me know