[R] Plotrix Trick

Lorenzo Isella lorenzo.isella at gmail.com
Thu Jun 24 17:38:29 CEST 2010


Dear Hrishi,
I am almost there, thanks. The only small problem left is to convince
also the colorbar to plot the values I want.
Consider the small snippet at the end of the email: colors and numbers
inside the cells are OK, but the legend shows the extremes of the log
transformed data instead of the original one.
Any suggestions? 
Cheers

Lorenzo


#########################################################

library(plotrix)


set.seed(1234)

myseq <- abs(rnorm(25))

myseq[20] <- 100 #introduce outlier!

A <- matrix(myseq, ncol=5,nrow=5)


pdf("test_color_scale_log-fixed.pdf")
oldpar<-par( mar = c(4.5,5, 2, 1) + 0.1,
 cex.axis=1.4,cex.lab=1.6,cex.main=1.6)
color2D.matplot(log(A),main="Title",c(0.2,1),c(0.2,0.5),c(0,0),
 xlab = "",
 ylab="",
show.legend=TRUE,
 show.values=0,vcol="black",vcex=1, axes=FALSE)
## axis(1,at=c(0.5,1.5,2.5,3.5,4.5),labels=prefix_vec_short)
## axis(2,at=rev(c(0.5,1.5,2.5,3.5,4.5)),labels=prefix_vec_short)
for(i in 1:5) {
        for(j in 1:5) {

text(i-0.5,j-0.5,formatC(A[6-j,i],format="f",digits=1),col="white")
        }
}
box()
par(oldpar) 
dev.off()






> Lorenzo,
> 
> This is a bit ugly but should work. Instead of using plotrix's
> show.values,
> use the text() command:
> 
> 
> for(i in 1:5) {
>         for(j in 1:5) {
>                 text(i-0.5,j-0.5,format(A[6-j,i],digits=3),col="white")
>         }
> }
> 
> -- 
> View this message in context:
> http://r.789695.n4.nabble.com/Plotrix-Trick-tp2265893p2266390.html
> Sent from the R help mailing list archive at Nabble.com.
>



More information about the R-help mailing list