[R] how to plot two surfaces with lattice::wireframe

Carl Witthoft carl at witthoft.com
Thu Oct 13 23:37:11 CEST 2011


Hi all,
I'd like to plot the Real and Imaginary parts of some f(z) as two 
different surfaces in wireframe (the row/column axes are the real and 
imag axes).  I know I can do it by, roughly speaking, something like

plotz <- expand.grid(x={range of Re(z)}, y={range of Im(z), groups=1:2)
plotz$func<-c(Re(f(z),Im(f(z))
wireframe(func~x*y,data=plotz,groups=groups)

But that seems like a clunky way to go, especially if I happen to have 
started out with a nice matrix of the f(z) values.

So, is there some simpler way to write the formula in wireframe?  I 
envision, for a matrix of complex values zmat,  pseudocode:

wireframe(c(Re(zmat),Im(zmat), groups=1:2)

  -- and yes, I'm fully aware that without a connection between the 
'groups' variable and zmat, this won't work as written.

All suggestions (including "read the help file for {some lattice func I 
didn't know about} ) greatfully accepted.

Carl
-- 
-----
Sent from my Cray XK6



More information about the R-help mailing list