[R] Fine Tuning Plotrix

Lorenzo Isella lorenzo.isella at gmail.com
Wed Mar 10 17:25:48 CET 2010


Hi Jim,
And thanks for helping. My (hopefully) last question concerns the use of 
a non-gray color scale.
How do I use e.g. a rainbow colorscale? This issue has already been raised

http://tinyurl.com/ylhcbra

and over there it is dealt with by hand. I just wonder whether anything 
similar is doable in the case of my matrix. In the following code 
snippet I simply try to normalize (i.e. every entry is mapped into 
[0,1]) my matrix and to use that as an argument to cellcolors, but the 
result is clearly not what I am trying to achieve.

rm(list=ls())
library(Cairo)
library(plotrix)
library(rimage)

set.seed(1234)
trivial_matrix<-matrix(rnorm(25),nrow=5)

CairoPDF("matrix2D.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(trivial_matrix,main="A trivial Plot",
 xlab = expression(paste(k)) ,
 ylab=expression(paste(R[g])),show.legend=TRUE,
 show.values=3,vcol="blue",vcex=1, 
axes=FALSE,cellcolors=normalize(trivial_matrix))
axis(1,at=c(0.5,1.5,2.5,3.5,4.5),labels=letters[1:5])
axis(2,at=rev(c(0.5,1.5,2.5,3.5,4.5)),labels=letters[1:5])
box()
par(oldpar)
dev.off()

Understanding this would probably get me going also with the use of a 
log scale for colors, as discussed in

http://tinyurl.com/ye5d8z8

Any suggestion is welcome.
Cheers

Lorenzo


> Hi Lorenzo,
> First, here is how to solve some of your problems: [...]
> For question 2, the answer is no right now, but I have added this 
> feature for the next version (thanks)
>
> and moving right along to question 4, no, you will have to call 
> color.legend directly, so you can specify the decimal places in that 
> call.
>
> Jim
>
>



More information about the R-help mailing list