Dear All, Please see the code snippet at the end of the email. I am using the color2D.matplot in Plotrix to plot a matrix. It works great, but there are a few things I cannot figure out (1) the value of cex.axis in the code snippet does not seem to affect the final pdf at all (at least on my system, Ubuntu 9.10, plotrix and Cairo installed from cran). How do I specify the size of the axis ticks and the corresponding numbers? (2) Can I specify the number of decimal figures in the max/min value in the legend? (3) Can I replace the numbers along the x-axis with e.g. c('a','b','c','d','e')? (4) Do I need to resort to color.legend if e.g. I want to rotate the legend and align it to the y axis? Many thanks Lorenzo ############################################################ rm(list=ls()) library(Cairo) library(plotrix) set.seed(1234) trivial_matrix<-matrix(rnorm(25),nrow=5) CairoPDF("matrix2D.pdf") par( mar = c(4.5,5, 2, 1) + 0.1) color2D.matplot(trivial_matrix,main="A trivial Plot",xlab = expression(paste(k)), ylab=expression(paste(R[g])),cex.axis=1.4,cex.lab=1.6, cex.main=1.6, show.legend=TRUE, show.values=1,vcol="blue", vcex=1, axes=TRUE) dev.off()
On 03/10/2010 10:12 AM, Lorenzo Isella wrote:> Dear All, > Please see the code snippet at the end of the email. > I am using the color2D.matplot in Plotrix to plot a matrix. > It works great, but there are a few things I cannot figure out > > (1) the value of cex.axis in the code snippet does not seem to affect > the final pdf at all (at least on my system, Ubuntu 9.10, plotrix and > Cairo installed from cran). How do I specify the size of the axis ticks > and the corresponding numbers? > (2) Can I specify the number of decimal figures in the max/min value in > the legend? > (3) Can I replace the numbers along the x-axis with e.g. > c('a','b','c','d','e')? > (4) Do I need to resort to color.legend if e.g. I want to rotate the > legend and align it to the y axis? > > Many thanks > > Lorenzo > > ############################################################ > > rm(list=ls()) > library(Cairo) > library(plotrix) > > set.seed(1234) > > trivial_matrix<-matrix(rnorm(25),nrow=5) > > CairoPDF("matrix2D.pdf") > par( mar = c(4.5,5, 2, 1) + 0.1) > > color2D.matplot(trivial_matrix,main="A trivial Plot",xlab > expression(paste(k)), > ylab=expression(paste(R[g])),cex.axis=1.4,cex.lab=1.6, cex.main=1.6, > show.legend=TRUE, show.values=1,vcol="blue", > vcex=1, axes=TRUE) > dev.off() >Hi Lorenzo, First, here is how to solve some of your problems: 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) 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) 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
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 > >
Apologies for the previous email, I think I got it sorted out now. Lorenzo rm(list=ls()) library(Cairo) 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,c(0,0),c(0,0),c(0,1),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) 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()