Umesh Srinivasan
2009-Nov-27 12:44 UTC
[R] plotting two surfaces simultaneously in a single panel
Hi, I have recently begun using the lattice package, and have been using the wireframe command to visualise matrices which are model outputs. I have been trying to plot two surfaces (from two matrices) simultaneously in one panel, to visualise intersections etc., but neither my attempts or trawling the net are helping me find how to do this. Can someone help? Thanks Cheers, Umesh Srinivasan NCBS-TIFR, Bangalore, India
Deepayan Sarkar
2009-Dec-02 14:46 UTC
[R] plotting two surfaces simultaneously in a single panel
On Fri, Nov 27, 2009 at 6:14 PM, Umesh Srinivasan <umesh.srinivasan at gmail.com> wrote:> Hi, > > I have recently begun using the lattice package, and have been using > the wireframe command to visualise matrices which are model outputs. I > have been trying to plot two surfaces (from two matrices) > simultaneously in one panel, to visualise intersections etc., but > neither my attempts or trawling the net are helping me find how to do > this.The documentation for wireframe mentions the use of 'groups' to do this, and the usual shortcut of using formulae of the form z1+z2 ~ x + y also works. The following seems to work as expected, subject to caveats mentioned in ?wireframe and ?panel.wireframe (there is no hidden surface removal going on, so intersections will not be shown correctly). df <- as.data.frame.table(volcano) names(df) <- c("x", "y", "height") df$sheight <- scale(df$height) wireframe(sheight + (-sheight) ~ x + y, df, aspect = c(1, .5)) -Deepayan