Re: ColorFunction
- To: mathgroup at smc.vnet.net
- Subject: [mg27746] Re: ColorFunction
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Wed, 14 Mar 2001 04:06:45 -0500 (EST)
- References: <98kodo$ppk@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Michael, Firstly, use ColorFunctionScaling -> False to stop scaling of the input to ColorFunction. Here is an extract from my colunmn in Mathematica in Education and Research 8..4 Specifying the colors of contour regions Suppose that we wish to draw several contour plots with Contours -> {z1,z2,..} and have the same colors correspond to the the same heights. The following function will construct an appropriate color function MakeColorFunction[(cntrs_)?OrderedQ, clrs_] /; Length[clrs] == Length[cntrs] + 1 := Function @@ {Which @@ Flatten[ {{#1 <= cntrs[[1]], clrs[[1]]}, Table[{Inequality[cntrs[[i]], Less, #1, LessEqual, cntrs[[i + 1]]], clrs[[i + 1]]}, {i, 1, Length[cntrs] - 1}], {cntrs[[-1]] <= #1, clrs[[-1]]}}]} For example, we get MakeColorFunction[{z1,z2,z3},{c1,c2,c3,c4}] Which[#1\[LessEqual]z1,c1,z1<#1\[LessEqual]z2,c2,z2<#1\[LessEqual]z3,c3, z3\[LessEqual]#1,c4]& Let's make a plot. << "Graphics`Colors`" cntrs = {-0.9, -0.6, -0.3, 0, 0.3, 0.6, 0.9}; clrs = {Red, Blue, LightSeaGreen, YellowBrown, Khaki, Green, Purple, Yellow}; ContourPlot[(Cos[x] + Sin[y])/2, {x, 0, 2*Pi}, {y, 0, 2*Pi}, Contours -> cntrs, ColorFunction -> MakeColorFunction[cntrs, clrs], ColorFunctionScaling -> False]; -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Michael Wild" <wild at ilt.fhg.de> wrote in message news:98kodo$ppk at smc.vnet.net... > Dear Colleagues, > I am trying to display a r-z-temperature field with ContourPlot. > How can I modify the ColorFunction command such that the > temperature range from > 100-200 K > 200-300 K > etc. is displayed in the same color no matter if the total > temperature range of the plot is 0 to 500 K or > 0 to 1000 K. > My current plot command is > ContourPlot[templim[r, z], {r, 0, 2}, {z, 0, 4}, PlotRange -> All, > ColorFunction -> (Hue[0.7(1 - 0.79*#)] &), > PlotPoints -> 150, AspectRatio -> 1/2, > Contours -> {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, > 1200, > 1300, 1400, 1500}] > Your help is very much appreciated > thanks > Michael > > >