[R] X Axis labeling with class zoo

Gabor Grothendieck ggrothendieck at gmail.com
Thu Oct 25 15:43:46 CEST 2007


You can pass oma= and mar= to plot.zoo.  This is apparent from the
argument list in ?plot.zoo or from args(plot.zoo)

On 10/25/07, John Theal <jtheal at free.fr> wrote:
> 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
> archives:
>
> library(zoo)
> # 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 =
> "zoo")
> 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(...) {
>    lines(...)
>    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 =
> 0.7)
>    }
> }
> 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