Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display values on heatmap in R

Tags:

r

heatmap

I am working on a heatmap using heatmap.2 and would like to know if there is anyway to display the values on all heatmap positions. For example for the area representing "1" and rating I would like to display value "43", for "2" and privileges the value 51 and so on.

My sample data is as follows: enter image description here

            rating complaints privileges learning raises critical advance
      1      43         51         30       39     61       92      45
      2      63         64         51       54     63       73      47
      3      71         70         68       69     76       86      48
      4      61         63         45       47     54       84      35
like image 301
Mdhale Avatar asked Jan 27 '14 17:01

Mdhale


2 Answers

Is this what you mean? By providing the data object as the cellnote argument, the values are printed in the heatmap.

heatmap.2(data,           # cell labeling
          cellnote=data,
          notecex=1.0,
          notecol="cyan",
          na.color=par("bg"))

enter image description here

like image 76
CMichael Avatar answered Sep 30 '22 18:09

CMichael


The answer is just for "For Cell labeling is there anyway not to display values that are 0".

cellnote=ifelse(data==0, NA, data) will work as you want.

like image 20
Zhilong Jia Avatar answered Sep 30 '22 17:09

Zhilong Jia