MathGroup Archive 2007

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

Search the Archive

Re: Does ColorFunction-> have different meanings to Plot3D

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83290] Re: [mg83276] Does ColorFunction-> have different meanings to Plot3D
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Sat, 17 Nov 2007 05:12:15 -0500 (EST)
  • References: <200711161041.FAA05001@smc.vnet.net>

congruentialuminaire at yahoo.com wrote:

>Hello Mathematica UG:
>
>I made a very simple 3D plot using a CF:
>
>Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2},  ColorFunction -> (Hue[#]
>&)]
>
>Then I made a contour plot of the identical function, also with CF:
>
>ContourPLot[Sin[x + y^2], {x, -3, 3}, {y, -2, 2},  ColorFunction ->
>(Hue[#] &)]
>
>Since I am using the identical function passed to the 2 plotting
>routines, I expect the color to show analogously. Specifically in the
>Plot3D, the color bands are straight and parallel to the y-axis. In
>the ContourPlot, the bands are curved with the contours.
>
>Is it possible to make the CF correspond so that when both plots are
>shown, the color shows the correspondence between the plots (since the
>functions plotted are the same)? Alternatively, is there some other CF
>I can use with ContourPlot to accomplish the desired result?
>
>TIA.
>
>Regards..Roger W.
>  
>
Look up ColorFunction in the help to discover that the arguments 
supplied to Plot3D and ContourPlot are:

Plot3D - x,y,z
ContourPlot - f contour levels

Therefore, there is no way to give ContourPlot a ColorFunction that will 
color things based on x values. On the other hand, you can give Plot3D a 
ColorFunction that will color based on z values:

Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, ColorFunction -> (Hue[#3]&)]

and

ContourPlot[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, ColorFunction -> 
(Hue[#] &)]

will plot with similar colors. Instead of ContourPlot, you might try 
DensityPlot as well:

DensityPlot[Sin[x + y^2], {x, -3, 3}, {y, -2, 2},  ColorFunction -> 
(Hue[#] &), PlotPoints -> 70]

Carl Woll
Wolfram Research


  • Prev by Date: Re: Get list of function variables?
  • Next by Date: Memory problem using NDSolve in For Loop
  • Previous by thread: Re: Does ColorFunction-> have different meanings to Plot3D
  • Next by thread: Re: Does ColorFunction-> have different meanings to Plot3D and