Nov 15, 2010

Color-coded contour lines with Mathematica

In ContourPlot, ContourStyle –> function can be used to color-code contour lines.For example, the number of contours is numC=20, then for each contour, the color is defined by a coloring function:

ContourStyle -> Table[{ColorData["Rainbow", (i - 1)/(numC - 1)]}, {i, numC}]

Of course, it is also necessary to set Contours –> numC.

Here are the examples, the famous peaks function from Matlab is used.

2D ContourPlot example:

colorcodedcontourlines

Turn 2D plot into the 3D one:

colorcodedcontourlines1

Another 3D example:

colorcodedcontourlines3

Download the notebook.

1 comment:

Yaroslav said...
This comment has been removed by the author.