Re: Contour line colors from z coord of a 3D plot
- To: mathgroup at smc.vnet.net
- Subject: [mg117269] Re: Contour line colors from z coord of a 3D plot
- From: JUN <noeckel at gmail.com>
- Date: Sun, 13 Mar 2011 05:27:36 -0500 (EST)
- References: <ilcq8k$igu$1@smc.vnet.net> <ilfgos$6p2$1@smc.vnet.net>
On Mar 12, 2:09 am, "Kevin J. McCann" <k... at KevinMcCann.com> wrote: > Except that Re[Log[x+I y]] produces a number and is continuous across > the axis: > Try: > > {Re[Log[-2.0 + I .0001]], Re[Log[-2.0]], Re[Log[-2.0 - I .0001]]} > > There is a branch cut there or at least that is where one usually puts > it, but that does not change the real part. > > Kevin > > On 3/11/2011 4:33 AM, Heike Gramberg wrote: > > > > > > > > > The lack of a plot along the negative real axis comes from the fact that Log[] has a > > branch cut along the negative real axis. Since the default setting for the Exclusions > > option in ContourPlot is Automatic, these points are excluded from the plot. > > If you want to include those points, you could set Exclusions->{} in ContourPlot. > > > Heike. > > > On 10 Mar 2011, at 21:04, Kevin J. McCann wrote: > > >> If you use a ListPlot3D and ListContourPlot instead, it will get rid of > >> the annoying and puzzling lack of a plot along the negative real axis. > > >> On 3/10/2011 6:43 AM, Bob Hanlon wrote: > >>> Module[{f, ch = Purple, cl = Yellow}, > >>> f[x_, y_] := Log[x + I y]; > >>> logre = Show[ > >>> Plot3D[Re[f[x, y]], > >>> {x, -2.4, 2.4}, {y, -2, 2}, > >>> PlotStyle -> Opacity[0.7], > >>> PlotRange -> {-3, 1.5}, > >>> ColorFunction -> > >>> (Blend[{cl, ch}, #3]&), > >>> MeshStyle -> Darker[Gray]], > >>> Graphics3D[ > >>> ContourPlot[Re[f[x, y]], > >>> {x, -2.4, 2.4}, {y, -2, 2}, > >>> Axes -> False, > >>> Contours -> Table[z, {z, -1, 1, .25}], > >>> ContourShading -> None, > >>> ContourStyle -> > >>> Table[ > >>> Blend[{cl, ch}, (z + 1)/2], > >>> {z, -1, 1, .25}]][[1]] /. > >>> {x_Real, y_Real} -> {x, > >>> y, -3}], > >>> ViewPoint -> {2.2, -4, 1.3}, > >>> ImageSize -> 400]] > > >>> Bob Hanlon > > >>> ---- recmath<recmat... at gmail.com> wrote: > > >>> ======================== === > >>> Hi there, > > >>> I'm trying to reproduce this very cool figure: > >>>http://en.wikipedia.org/wiki/File:NaturalLogarithmRe.png > > >>> Problem: I can't get the contour lines color-matched to the 3D > >>> surface, which is colored according to it's height. My code is below, > >>> can anyone help? > > >>> Module[{f}, f[x_, y_] := Log[x + I y]; > > >>> logre = Show[Plot3D[Re[f[x, y]], {x, -2.4, 2.4}, {y, -2, 2}, > >>> PlotStyle -> Opacity[0.7], Axes -> True, Boxed -> = True, > >>> PlotRange -> {Automatic, Automatic, {-3, 4}}, > >>> ColorFunction -> (Blend[{Yellow, Purple}, #3]&)], > >>> Graphics3D[ > >>> ContourPlot[Re[f[x, y]], {x, -2.4, 2.4}, {y, -2, 2}, > >>> Axes -> False, ContourShading -> None, > >>> ContourStyle -> Purple][[ > >>> 1]] /. {x : _Real, y : _Real} -> {x, y, -3}], > >>> ViewPoint -> {2.2, -4, 1.3}, ImageSize -> 300 > >>> ] > >>> ] Two suggestions on how to get around that little gap on the branch cut would be: a) Plot the function f[x_, y_] := ComplexExpand[Re[Log[x + I y]]] in both the contour and density plots. b) Add Exclusions -> None to the contour plot and ExclusionsStyle -> Automatic to the density plot. (a) is probably better because it plots what you really want, without having to worry about the branch cut at all (as Kevin already noted above). Jens