[R] Fine Tuning Plotrix
Jim Lemon
jim at bitwrit.com.au
Wed Mar 10 05:27:10 CET 2010
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
More information about the R-help
mailing list