[R] Levelplot without margins

Deepayan Sarkar deepayan.sarkar at gmail.com
Sun Oct 4 17:03:03 CEST 2009


On Mon, Sep 28, 2009 at 9:08 AM, Antje <antje.niederlein at yahoo.de> wrote:
> I had a bit success with the following usage:
>
> my.padding <- list(layout.heights = list(
>                        top.padding = 0,
>                        main.key.padding = 0,
>                        key.axis.padding = 0,
>                        axis.xlab.padding = 0,
>                        xlab.key.padding = 0,
>                        key.sub.padding = 0),
>                layout.widths = list(
>                        left.padding = 0,
>                        key.ylab.padding = 0,
>                        ylab.axis.padding = 0,
>                        axis.key.padding = 0,
>                        right.padding = 0)
>                )
>
> levelplot(..., scales = list(draw = FALSE), colorkey = FALSE, xlab = NULL,
> ylab = NULL, par.settings = my.padding)
>
>
> But still I have a upper and lower margin (left and right margins are gone)
>
> What else do I have to do?

Actually, for your use it's easier to bypass lattice and use grid
directly. You can still use panel.levelplot() as a low level drawing
function. For example, using the volcano data:

my.matrix <- volcano

library(grid)
grid.newpage()
pushViewport(viewport(xscale = c(0, 1 + ncol(my.matrix)), yscale =
c(0, 1 + nrow(my.matrix))))
panel.levelplot(col(my.matrix), row(my.matrix), my.matrix,
                subscripts=TRUE, at = do.breaks(range(my.matrix), 30))


Of course, this requires you to do some limit calculations beforehand,
and the arguments of the panel function are not always obvious. You
can use lattice to take care of these things for you:


p <- levelplot(volcano)
grid.newpage()
pushViewport(viewport(xscale = p$x.limits, yscale = p$y.limits))
do.call(panel.levelplot, trellis.panelArgs(p, 1))

-Deepayan




More information about the R-help mailing list