[R] Combining 3D/2D plots

David Winsemius dwinsemius at comcast.net
Fri Dec 11 04:43:25 CET 2009


On Dec 10, 2009, at 9:09 PM, David Winsemius wrote:

> Take a look at Figure 13.7 in Sarkar's Lattice book, all of whose  
> figures are on the web page for the book, I believe.  ... yep...
>
> http://lmdvr.r-forge.r-project.org/figures/figures.html   (tried to  
> extract the link to that page but you will need to navigate the page  
> yourself.

My efforts to reproduce that figure were more difficult than I  
expected, so here is some "punctuated" code that may survive better  
than my initial cut and paste failures:

panel.3d.contour <-
function(x, y, z, rot.mat, distance,
              nlevels = 20, zlim.scaled, ...) {
add.line <- trellis.par.get("add.line")
panel.3dwire(x, y, z, rot.mat, distance,
                  zlim.scaled = zlim.scaled, ...)
clines <- contourLines(x, y, matrix(z, nrow = length(x), byrow = TRUE),
                            nlevels = nlevels)
for (ll in clines) {
m <- ltransform3dto3d(rbind(ll$x, ll$y, zlim.scaled[2]),
rot.mat, distance)
panel.lines(m[1,], m[2,], col = add.line$col,
            lty = add.line$lty, lwd = add.line$lwd)
                    }
                                             }

fig13.7 <-wireframe(volcano, zlim = c(90, 250), nlevels = 10,
aspect = c(61/87, .3), panel.aspect = 0.6,
panel.3d.wireframe = "panel.3d.contour", shade = TRUE,
screen = list(z = 20, x = -60))

fig13.7 # sometimes need to explicitly call the print function for  
lattice objects

-- 
David
>
> On Dec 10, 2009, at 8:11 PM, Bruno Goncalves wrote:
>
>> http://www.gradient-da.com/img/temperature%20surface%20plot%20470x406.JPG
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> ______________________________________________
> R-help at 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list