Message-ID: <CADfFDC4N-yG4JA_cNfh9nLRivr4b=mYSiKF1c4DLC1Q_7R1m1g@mail.gmail.com>
Date: 2011-10-15T16:00:10Z
From: Deepayan Sarkar
Subject: how to plot two surfaces with lattice::wireframe
In-Reply-To: <4E975A07.40202@witthoft.com>
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? ?I
This 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