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
Hi Carl, I have no idea what z or f(z) are, but maybe outer will help you: wireframe(outer(seq(0,5,length.out=50),seq(2,4,length.out=40),function(x,y)sin(x*y))) cheers. Am 13.10.2011 23:37, schrieb Carl Witthoft:> 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-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. Uwe Koch-Gromus
Deepayan Sarkar
2011-Oct-15 16:00 UTC
[R] how to plot two surfaces with lattice::wireframe
On Fri, Oct 14, 2011 at 3:07 AM, Carl Witthoft <carl at witthoft.com> wrote:> 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? ?IThis is reasonably simple: fz <- matrix(complex(real = 1:100, imaginary = 101:200), 10, 10) zr <- as.vector(row(fz)) zc <- as.vector(row(fz)) wireframe(Re(fz) + Im(fz) ~ zr + zc) The as.vector() are needed because matrix x and y in the formula have a special meaning. -Deepayan
Maybe Matching Threads
- Plotting Two Surfaces in one plot with wireframe() using groups=
- how to draw manifold?
- 3D surface plot with wireframe or persp?
- : (Lattice): Overlaying more than one trend surface using contourplot() and wireframe()
- persp or wireframe 3D plot: how can I independently adjust linewidth of the 'surface' and framebox?