[R] Reducing space around lattice wireframe plots

Karl Ove Hufthammer Karl.Hufthammer at math.uib.no
Fri May 30 17:16:42 CEST 2008


Dear R-help.

When plotting 3D wireframe plots with the lattice package, there is often 
a lot of space between the actual plot (i.e., cube) and panel borders. For
a single wireframe, this is not a problem, but when plotting multiple
wireframes, the wasted space decreases the size of the plots very much.

Is there a way to decrease this space/margin? I could not find any
information about it in the documentation.

Here is example code for two panels showing the problem.

    library(MASS)
    library(lattice)
    n = 10^3
    x1 = rnorm(n)
    y1 = 3 * x1 + 5 * rnorm(n)
    x2 = rnorm(n)
    y2 = 3 * rnorm(n) + 5 * rnorm(n)
    ran = c(range(c(x1, x2)), range(c(y1, y2)))
    xy1 = con2tr(kde2d(x1, y1, n = 30, lims = ran))
    xy1$dist = "correlated"
    xy2 = con2tr(kde2d(x2, y2, n = 30, lims = ran))
    xy2$dist = "uncorrelated"
    xy = rbind(xy1, xy2)
    wireframe(z ~ x * y | dist, xy, screen = list(z = 16, y = -5, x = -47))

-- 
Karl Ove Hufthammer



More information about the R-help mailing list