Re: ColorFunction and question about how to use it

• To: mathgroup at smc.vnet.net
• Subject: [mg101686] Re: ColorFunction and question about how to use it
• From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
• Date: Tue, 14 Jul 2009 05:36:39 -0400 (EDT)
• References: <h3cbe2\$fkn\$1@smc.vnet.net>

```Hi David,

Replace the "->" in your Function definition with a comma and you're
fine. The second surface is blue because that's how the default
lighting appears on the surface you've drawing.

As to your third question: something like the following is probably
what you described.

f[x_, y_] = Sin[x y];
g[x_, y_] = D[f[x, y], x]^2 + D[f[x, y], y]^2;
\[Epsilon] = 0.1;
cf[c_] := \[Piecewise] {
{{Opacity[1], Red}, 0 <= c <= \[Epsilon]},
{{Opacity[0.3], Gray}, c > \[Epsilon]}
}
Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}, ColorFunctionScaling -> False,
ColorFunction -> Function[{x, y, z}, cf[g[x, y]]],
PlotPoints -> 100]

Cheers -- Sjoerd

On Jul 12, 11:46 am, David <david.b.a.epst... at googlemail.com> wrote:
> Here is some Mathematica code
>
> In[1]:= Options[Plot3D]
>
> Out[1]= {AlignmentPoint -> Center, AspectRatio -> Automatic,
>  Axes -> True, AxesEdge -> Automatic, AxesLabel -> None,
>  AxesOrigin -> Automatic, AxesStyle -> {}, Background -> None,
>  BaselinePosition -> Automatic, BaseStyle -> {},
>  BoundaryStyle -> GrayLevel[0], Boxed -> True,
>  BoxRatios -> {1, 1, 0.4}, BoxStyle -> {}, ClippingStyle -> Automatic,
>   ColorFunction -> Automatic, ColorFunctionScaling -> True,
>  ColorOutput -> Automatic, ContentSelectable -> Automatic,
>  ControllerLinking -> Automatic, ControllerMethod -> Automatic,
>  ControllerPath -> Automatic, CoordinatesToolOptions -> Automatic,
>  DisplayFunction :> \$DisplayFunction, Epilog -> {},
>  Evaluated -> Automatic, EvaluationMonitor -> None,
>  Exclusions -> Automatic, ExclusionsStyle -> None, FaceGrids -> None,
>  FaceGridsStyle -> {}, Filling -> None, FillingStyle -> Opacity[0.5],
>  FormatType :> TraditionalForm, ImageMargins -> 0.,
>  ImagePadding -> All, ImageSize -> Automatic, LabelStyle -> {},
>  Lighting -> Automatic, MaxRecursion -> Automatic, Mesh -> Automatic,
>  MeshFunctions -> {#1 &, #2 &}, MeshShading -> None,
>  MeshStyle -> Automatic, Method -> Automatic,
>  NormalsFunction -> Automatic, PerformanceGoal :> \$PerformanceGoal,
>  PlotLabel -> None, PlotPoints -> Automatic,
>  PlotRange -> {Full, Full, Automatic}, PlotRangePadding -> Automatic,
>  PlotRegion -> Automatic, PlotStyle -> Automatic,
>  PreserveImageOptions -> Automatic, Prolog -> {},
>  RegionFunction -> (True &), RotationAction -> "Fit",
>  SphericalRegion -> False, Ticks -> Automatic, TicksStyle -> {},
>  ViewAngle -> Automatic, ViewCenter -> Automatic,
>  ViewMatrix -> Automatic, ViewPoint -> {1.3, -2.4, 2.},
>  ViewRange -> All, ViewVector -> Automatic, ViewVertical -> {0, 0, 1},
>   WorkingPrecision -> MachinePrecision}
>
> In[2]:=
> Plot3D[x + y, {x, -2, 2}, {y, -2, 1},
>  ColorFunction -> Function[{x, y, z} -> Hue[z]]]
>
> Plot3D[x + y, {x, -2, 2}, {y, -2, 1}]
> -------------------------------------------------------------------------=
----
> The first Plot3D command gives me only black and white. Why is that?
> Otherwise it looks fine.
> The second Plot3D command gives me the graph in a uniform blue. Why is
> that? Apart from the colour, the two graphs look the same.
>
> What I am actually trying to do is more complicated, but I need to
> understand the simplest situations first: I have a given real valued
> function f of two variables. I can show that there are exactly two
> {x,y} locations at which the two partial derivatives of f are
> simultaneously zero. I would like to demonstrate this through Plot3D,
> for example by plotting the sum of the squares of the two partial
> derivatives. The function surface should be mostly transparent, but
> the surface would be coloured (say red) whenever the sum of squares
> lies in the closed interval [0,epsilon], with the value of the
> positive number epsilon under user control. Transparency would enable
> one to see the zeros even if the surface is in the way.
>
> My many attempts to achieve this have all failed.
>
> Thanks for any help.
>
> David

```

• Prev by Date: Re: ColorFunction and question about how to use it
• Next by Date: Re: ColorFunction and question about how to use it
• Previous by thread: Re: ColorFunction and question about how to use it
• Next by thread: Spell Check on a Mac