[R] X Axis labeling with class zoo

John Theal jtheal at free.fr
Thu Oct 25 12:00:39 CEST 2007

Hi Gabor,

Sorry to bother you again, I'm having trouble controlling the margins  
on a multiplot window.  Using a previous example you posted in the  

# test data
z <- structure(c(21,34,33,41,39,38,37,28,33,40),
                 index = structure(c(8044,8051,8058,8065,8072,
                 8079,8086,8093,8100,8107), class="Date"), class =  
set.seed(1) # needed to make it reproducible
jx1 <- rnorm(10); jx2 <- rnorm(10); jx3 <- rnorm(10)
# create a zoo class data using the random vectors.
jx  <- cbind(jx1,jx2,jx3)
z1  <- zoo(jx, index(z))

# 1. plot.zoo solution using custom panel function, my.panel
my.panel <- function(...) {
    if (parent.frame()$j == ncol(z1)) {
       # following line only if non-labelled ticks wanted for each point
       axis(1, at = time(z1), lab = FALSE)
       ix <- seq(1, length(z1), 3)
       labs <- format(time(z1)[ix], "%b-%d")
       axis(1, at = time(z1)[ix], lab = labs, tcl = -0.7, cex.axis =  
par(mai=c(.8, .8, .2, .9))
plot(z1, panel = my.panel, xaxt = "n")

Calling par(mai...)) as above doesn't seem to adjust the margins.  I  
am interested in adjusting the margin on the right hand side of the  
figure, but it is not readily apparent how to do this.  Is there an  
alternative parameter for a multiplot window?  I have also tried  
using par(oma=c()) but that doesn't seem to work either.

More information about the R-help mailing list