Skip to content
Prev 274686 / 398506 Next

right justify right-axis tick values in lattice

On Sun, Oct 16, 2011 at 7:20 PM, David Winsemius <dwinsemius at comcast.net> wrote:
Using format() and a fixed-width font is not too difficult:

panel.right <- function(x, y, ...) {
    panel.barchart(x, y, ...)
    panel.axis(side="right", at = pretty(y),
               labels = format(pretty(y)),
               text.fontfamily = "Courier",
               outside=TRUE)
}

A more general solution is not simple, and I think trying to modify
the current panel.axis() to incorporate it would make it unnecessarily
complicated. If one is desired, that should either be a separate
specialized function, or a clean reimplementation of panel.axis() from
scratch.

If anyone contributes such a function, I would be happy to include it
in lattice.

-Deepayan