[R] heatmap with values

Jim Lemon jim at bitwrit.com.au
Wed Jun 15 11:37:42 CEST 2011


On 06/14/2011 08:53 PM, Agustin Lobo wrote:
> Hi!
> I'm displaying a contingency table with heatmap():
>> svm.predPix.tabla
>
> svm.predPix CC DD LL NN NN2
>          CC  22  0  3  8   3
>          DD   0 27  0  1   0
>          LL   1  1 90  3   7
>          NN   2  0  1 11   4
>          NN2  0  0  5  1  20
>
>
>> heatmap(svm.predPix.tabla[5:1,], Rowv=NA, Colv=NA,col =
> rev(heat.colors(32)), scale="column",  margins=c(5,10))
>
> and I'm happy with the plot except that I would like to have the actual
> values displayed within each cell.  Any help on how
> to achieve this?
>
> Data in
> https://sites.google.com/site/openfiles2/home/svm.predPix.tabla.rda
>
Hi Agustin,
I was going to send the code from color2D.matplot to display the values, 
but it required so much modification that I would suggest:

library(plotrix)
color2D.matplot(svm.predPix.tabla,show.values=TRUE,axes=FALSE,
  xlab="",ylab="")
axis(1,at=0.5:4.5,labels=rownames(svm.predPix.tabla))
axis(2,at=4.5:0.5,labels=colnames(svm.predPix.tabla))

Jim



More information about the R-help mailing list