On 5/21/08, Michael Kubovy <[EMAIL PROTECTED]> wrote: > Dear R-helpers, > > (1) How do I add a 'top' label symmetric with the 'bottom' label' in: > > axis.td <- > function(side, ...) > { > ylim <- current.panel.limits()$ylim > switch(side, > bottom = { > panel.axis(side = side, outside = TRUE, rot = 0, > at = 1:3, labels = c(2.0, 3.5, 5.0)) > }, > top = { > panel.axis(side = side, outside = TRUE, rot = 45, > at = 1:3, labels = c(0.143, 0.250, 0.357)) > }, > axis.default(side = side, ...)) > } > > xyplot(1:3 ~ 1:3, type = 'b', axis = axis.td, xlab = 'bottom', ylab = > 'left', aspect = 'xy')
No good way ('main' will be centered differently). I will consider adding a new row for something like xlab.top (and a column for a ylab.right). > (2) Is there a simpler way to create the two axes? Simpler? Probably not. ?axis.default has this and another approach as examples; in theory, the other method is better because it gives lattice a chance to automatically allocate space for the labels, but that doesn't happen yet in practice. > (3) A bit more complex: > > df <- data.frame(x = rep(1:3, 3), y = 1:9, z = factor(rep(1:3, each = > 3))) > xyplot(y ~ x | z, df, axis = axis.td, xlab = 'bottom', ylab = 'left', > layout = c(3, 1), aspect = 'xy', type = 'b') > > Here I would like to have a different pair of top and bottom axes for > each panel (i.e., different labels at 1:3), and a different top and > bottom label. You could use current.column() and current.row() inside axis.td(). The different bottom labels are easy: xlab = c("one", "two", "three"), but labels on the top are not. Of course, you could add a label from inside each axis.td call, and add some space for them manually. -Deepayan ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.