Wolfram ResearchProductsPurchasingServices & ResourcesAbout UsOur Sites
Mathematica Technical FAQs Services & Resources / Mathematica / Kernels & Programming
-----
 /
Symbols
*Mathematica
*Network Mathematica
*webMathematica
*gridMathematica
*Personal Grid Edition
*Wolfram Workbench
*Wolfram Education Group
*Application Packages
*Mathematica for Students
*Mathematica CalcCenter
*Publicon
*A New Kind of Science Explorer
*Mathematical Explorer
*Mathematica Teacher's Edition
*Calculus WIZ
*Mathematica Player
*Ask about this page
*Print this page
*Email this page
*Give us feedback
*
Sign up for our newsletter:

ColorFunction


Usage Message:

ColorFunction is an option for various graphics functions which specifies a function to apply to z values to determine the color to use for a particular x, y region.

Attributes[ColorFunction] = {Protected}


Notes:

ColorFunction is an option in ContourGraphics , ContourPlot , DensityGraphics , DensityPlot , ListContourPlot , ListDensityPlot , ListPlot3D , Plot3D , Raster , and SurfaceGraphics .

In ContourGraphics , ContourPlot , and ListContourPlot , if the contour levels are given by a list c the argument passed to the value of the ColorFunction option for each contour will be 0.0, 1.0, or (c[[k]] + c[[k-1]] - First[c] - z1)/(z2 - z1 + Last[c] - First[c]) for k=2 through Length[c], where z1 and z2 are specified by the value of the PlotRange option.

In DensityGraphics , DensityPlot , and ListDensityPlot , the argument passed to the value of the ColorFunction option for each cell is given by (z - z1)/(z2 - z1), where z is the value in the cell, and z1 and z2 are specified by the PlotRange option.

In ListPlot3D , Plot3D , and SurfaceGraphics , the argument passed to the value of the ColorFunction option for each rectangle will be (z - z1)/(z2 - z1), where z is the average of the values at the corners of a rectangle, and z1 and z2 are specified by the PlotRange option.

A useful device for studying the arguments that are passed to the ColorFunction option is to include an operation such as AppendTo in the value of the ColorFunction option to record those arguments. For example:

In[1]:= {z1, z2} = {-1, 5};

In[2]:= c = {1.0, 1.5, 2.0,2.5, 3.0};

In[3]:= cf = {};

In[4]:= ContourPlot[x, {x, 0, 4}, {y, 0, 1},
                    PlotRange -> {z1, z2},
                    Contours -> c,
                    ColorFunction :> ((AppendTo[cf, #]; GrayLevel[#]) &)]
Out[4]= -ContourGraphics-

Here are the arguments that were passed to the value of the ColorFunction option, and for comparison the arguments computed using the values of the Contours and PlotRange options.

In[5]:= cf

Out[5]= {0.3125, 0.4375, 0.5625, 0.6875, 0., 1.}

In[6]:= Join[Table[(c[[k]] + c[[k-1]] - First[c] - z1)/
            (z2 - z1 + Last[c] - First[c]), {k, 2, Length[c]}], 
                                   {0.0, 1.0}]

Out[6]= {0.3125, 0.4375, 0.5625, 0.6875, 0., 1.}


Additional Online Documentation:

Mathematica 3.0
http://documents.wolfram.com/v3/RefGuide/ColorFunction.html

Mathematica 4.0
http://documents.wolfram.com/v4/RefGuide/ColorFunction.html




 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy