[R] tick marks on mfrow=c(3,3) plot

James Edward Marca jmarca at translab.its.uci.edu
Tue May 2 18:33:30 CEST 2000


On Mon, May 01, 2000 at 10:19:39AM -0700, Tony Long wrote:
> I am generating an array of similar plots using the par(mfrow=c(3,3))
> method.  Everything works fine except the plot only puts y-axis tick marks
> on cells in column one and x-axis tick marks on cells in row three.  I
> would like tick marks on both the x and y axix of all 9 plots in my array.
> 
> I am generating plots using the following two functions
> 
> three.by.three.plot <- function(ss)
> {
> par(mfrow=c(3,3))
> sub.plot(ss,1.5,0.02)
> sub.plot(ss,1.5,0.04)
> etc
> par(mfrow=c(1,1))
> }
> 
> sub.plot <- function(ss,gamma, prv)
> {
> plot(c(5,20,50),ss[ss[,"gam"]==gamma & ss[,"prev"]==prv,"x_Power"],
>       type = "n", xlab="4Nc", ylab="Power",xlim=c(0,55), ylim=c(0,1),las=1)
> lines(c(5,20,50),ss[ss[,"gam"]==gamma & ss[,"prev"]==prv,"x_Power"],
>       type ="b",lty=2, pch=15,mkh=0.11)
> ....plus some other lines commands....
> }
> 
> 
> Any suggestions???
> Thanks in advance.  Tony

I hacked your functions a bit to get them to work with artificial 
data, and had no problems.

my code:

three.by.three.plot <- function(ss)
  {
    par(mfrow=c(3,3))
    sub.plot(ss,-1,-1)
    sub.plot(ss,-1,0)
    sub.plot(ss,-1,1)
    sub.plot(ss,0,-1)
    sub.plot(ss,0,0)
    sub.plot(ss,0,1)
    sub.plot(ss,1,-1)
    sub.plot(ss,1,0)
    sub.plot(ss,1,1)
  }

sub.plot <- function(ss,gamma,prv)
  {
    plot(ss[ss[,"y"]==gamma & ss[,"z"]==prv,"x"],
         ss[ss[,"y"]==gamma & ss[,"z"]==prv,"plot.values"],
         type="n", xlab="4Nc", ylab="Power", las=1)
    lines(ss[ss[,"y"]==gamma & ss[,"z"]==prv,"x"],
          ss[ss[,"y"]==gamma & ss[,"z"]==prv,"plot.values"],
          type="b",lty=2,pch=15,mkh=0.11)
  }
z<-rnorm(400)
z[z < -1]<- -1
z[z > 1 ] <- 1
z[ z!= -1 & z != 1 ] <- 0
y<-rnorm(400)
y[y < -1]<- -1
y[y > 1 ] <- 1
y[ y!= -1 & y != 1 ] <- 0
x<- (1:400)/400
plot.values<- cos(x)
xyz <- cbind(x,y,z,plot.values)
three.by.three.plot(xyz)

tick marks all show up.  I'm using R 1.0.0 on Win98.  

James Marca
jmarca at translab.its.uci.edu
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list