[R] Immutable ticks using ts.plot?

Phil Morefield philmorefield at yahoo.com
Tue Apr 26 15:19:20 CEST 2011


Hello all-
 
What I'm going for here is a stack of four time series plots that use a common X axis on the bottom plot. And setting up customized tick marks on each plot that help illustrate the respective trends. Here's my code:
 
#### Start ####
fig_data <- ts(read.csv("F:/mydata.csv"), start=2000, end=2010, freq=1)
opar = par()
plot(fig_data, ann = FALSE, plot.type = "multiple", yaxt='n',xaxt = "n", panel=function(...){
  for (i in 1:4){
    if (i == 1){
      ts.plot(fig_data[,i],lwd=3,col="red", gpars=list(yaxp=c(80,90,2),xaxt = 'n', ann=FALSE))
      abline(v=2007, lty = "dashed", col = "grey")
    }
    if (i == 2){
      ts.plot(fig_data[,i],lwd=3,col="green", gpars=list(yaxp=c(65,75,2),xaxt = 'n', ann=FALSE))
      abline(v=2007, lty = "dashed", col = "grey")
    }
    if (i == 3){
      ts.plot(fig_data[,i], lwd=3,col="blue",gpars=list(yaxp=c(32,36,2),xaxt = 'n', ann=FALSE))
      abline(v=2007, lty = "dashed", col = "grey")
    }
    if (i == 4){
      ts.plot(fig_data[,i],lwd=3,col="brown", gpars=list(yaxp=c(155,170,2), yaxt='n', ann=FALSE))
      abline(v=2007, lty = "dashed", col = "grey")
    }
    }
  }
)
#### End ####
 
My problem is that for the bottom plot ( when i == 4) I have no control over the default ticks. yaxt = 'n' has no effect, nor does xaxt = 'n'. However I can add ticks with with yaxp or xaxp; I just can't remove the existing ticks. Is this known/correct behavior? Am I overlooking some way to remove those default ticks?
 
Thanks,
 
Phil



More information about the R-help mailing list