MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ColorFunction and question about how to use it

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101675] Re: [mg101635] ColorFunction and question about how to use it
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Tue, 14 Jul 2009 05:34:36 -0400 (EDT)
  • References: <200907120949.FAA16148@smc.vnet.net>

Hi,

a pure Function doesn't contain a Rule. If you want color the partial
derivatives you can just do it inside the ColorFunction. Maybe something
like that

PlotZeroDerivatives3D[
  expr_, {x_Symbol, minx_, maxx_}, {y_Symbol, miny_, maxy_}] := 
 Module[{df, maxValue},
  df = #.# &[{D[#, x], D[#, y]} &@expr];
  maxValue = 
   First@NMaximize[{df, minx <= x <= maxx && miny <= y <= maxy}, {x, 
      y}]; Plot3D[expr, {x, minx, maxx}, {y, minx, maxx}, 
     ColorFunction -> Function[{xx, yy, zz}, 
     With[{dfAtxy = df /. {x -> xx, y -> yy}}, 
      Directive[Opacity[(maxValue - dfAtxy)/maxValue],
        ColorData["SunsetColors"][dfAtxy/maxValue]]]
     ], ColorFunctionScaling -> False, PlotRange -> All, 
   PlotPoints -> 30]
  ];
PlotZeroDerivatives3D[
 Exp[-(x^2 + y^2)]*Sin[x y], {x, -1, 1}, {y, -1, 1}]

Cheers
Patrick




On Sun, 2009-07-12 at 05:49 -0400, David 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: NDSolve problem
  • Previous by thread: Re: ColorFunction and question about how to use it
  • Next by thread: Re: ColorFunction and question about how to use it