Re: Contour line colors from z coord of a 3D plot
- To: mathgroup at smc.vnet.net
- Subject: [mg117173] Re: Contour line colors from z coord of a 3D plot
- From: Helen Read <readhpr at gmail.com>
- Date: Thu, 10 Mar 2011 16:01:50 -0500 (EST)
- References: <ilacfg$23d$1@smc.vnet.net>
You might also want to draw the contours on the surface itself, which
you can do using MeshFunctions.
Module[{f, cvals}, f[x_, y_] := Log[x + I y];
cvals = Range[-3, 1, 0.3];
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] &),
MeshFunctions -> {#3 &}, Mesh -> {cvals}],
Graphics3D[
ContourPlot[Re[f[x, y]], {x, -2.4, 2.4}, {y, -2, 2},
Axes -> False, ContourShading -> None,
ColorFunction -> (Blend[{Yellow, Purple}, #] &),
ContourStyle ->
Table[Directive[Blend[{Yellow, Purple}, i]], {i, cvals}],
Contours -> cvals][[1]] /. {x : _Real, y : _Real} -> {x,
y, -3}], ViewPoint -> {2.2, -4, 1.3}, ImageSize -> 300]]
HPR
On 3/10/2011 6:25 AM, Heike Gramberg wrote:
> What you could do is to supply a list of contour values to ContourPlot using the Contours option,
> and then set the colour of each of the contours by setting the ContourStyle option to a corresponding list of colours, e.g.
>
> Module[{f, cvals}, f[x_, y_] := Log[x + I y];
> cvals = Range[-3, 1, 0.3];
> 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,
> ColorFunction -> (Blend[{Yellow, Purple}, #]&),
> ContourStyle ->
> Table[Directive[Blend[{Yellow, Purple}, i]], {i, cvals}],
> Contours -> cvals][[1]] /. {x : _Real, y : _Real} -> {x,
> y, -3}], ViewPoint -> {2.2, -4, 1.3}, ImageSize -> 300]]
>
> Heike.
>
> On 9 Mar 2011, at 11:57, recmath 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
>> ]
>> ]
>>
>