 
 
 
 
 
 
RE: Fill the space surrounded by two contours lines with different colors
- To: mathgroup at smc.vnet.net
- Subject: [mg36458] RE: [mg36422] Fill the space surrounded by two contours lines with different colors
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 7 Sep 2002 02:54:45 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Jun Lin,
Here is an example.
Needs["Graphics`Colors`"]
Let's make a contour plot of this function.
f[x_, y_] := Sin[x]Sin[2y]
Let's specify the exact contours to use. I got rid of the 0. contour because
it is difficult to obtain in this plot.
contourvalues = Complement[Range[-1, 1, 0.2], {0.}]
{-1, -0.8, -0.6, -0.4, -0.2, 0.2, 0.4, 0.6, 0.8, 1.}
Now we define a ColorFunction for the plot. I actually colored two different
bands to show how you can make a general color function to give each band a
desired color.
cfun[z_] :=
  Which[
    -0.6 < z < -0.42, RoyalBlue,
    0.4 < z < 0.6, Red,
    True, White]
ContourPlot[f[x, y], {x, 0, Pi}, {y, 0, Pi},
    PlotPoints -> 30,
    ColorFunctionScaling -> False,
    ColorFunction -> cfun,
    Contours -> contourvalues];
Using the option ColorFunctionScaling -> False says that the z value will be
the actual value of f[x,y]. Otherwise, in general, it will be scaled between
0 and 1. It is easier to write a color function when z is the actual value
of the function.
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: Jun Lin [mailto:jl_03824 at yahoo.com]
To: mathgroup at smc.vnet.net
I need to fill the space between two contour lines, C1 and C2, with
red color, and leave the other place white. What trick I have to use?
Any suggestion and advice will be appreciated.
Jun Lin

