0
library(NMF) # other packages are welcome
car<-as.matrix(cars)
car[car<18]<-0
car[car>=18]<-1
aheatmap(car)

enter image description here

I would like to see only two colors in the legend: the 0 represents blue and 1 represents red.

lmo
  • 37,904
  • 9
  • 56
  • 69
Ming
  • 181
  • 2
  • 10
  • The number of breaks in the legend can be changed [see documentation](http://nmf.r-forge.r-project.org/aheatmap.html): `aheatmap(car,color = "-RdYlBu2:1")`. However you will still have the graduation – Mitra Apr 12 '16 at 16:36
  • Yes, it works better in your way, but the sill the graduation exits. Thanks all the same. –  Ming Apr 12 '16 at 17:37
  • What about changing the red-blue style to yellow-red style? –  Ming Apr 12 '16 at 18:55
  • [Please refer to the documentation](http://nmf.r-forge.r-project.org/aheatmap.html) __When the coluor palette is specified with a single value, and is negative or preceded a minus ('-'), the reversed palette is used. The number of breaks can also be specified after a colon (':'). For example, the default colour palette is specified as '-RdYlBu2:100'.__ so in your case, you can use the yellow-red palette from RColorBrewer: `aheatmap(car,color = "-YlOrRd:1")` – Mitra Apr 13 '16 at 10:38

0 Answers0