MathGroup Archive 2007

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

Search the Archive

ColorFunction help?

  • To: mathgroup at
  • Subject: [mg74888] ColorFunction help?
  • From: AES <siegman at>
  • Date: Tue, 10 Apr 2007 05:15:22 -0400 (EDT)
  • Organization: Stanford University

Some time back I asked about creating what a respondent later called 
"White to Color" color functions for contour and density plots, and 
after some further experimentation I've found that if I define

      k1=xx;  k2=yy;  k3=zz;
      myPlotColor[i_] = RBGColor[1 - k1 i, 1 - k2 i, 1 - k3 i]

with k1, k2, k3 each set equal to either 0 or 1, and then use


in the plot command, I get just the results I want.  For example if I 
execute the seven lines (either in a single cell or as separate cells) 

   k1 = 0; k2 = 1; k3 = 1;
   red[i_] = RGBColor[1 - k1 i, 1 - k2 i, 1 - k3 i];

   gCP = ContourPlot[(x + y)/2, {x, 0, 1}, {y, 0, 1}, 
            ColorFunction -> red];

   k1 = 1; k2 = 0; k3 = 1;

   green[i_] = RGBColor[1 - k1 i, 1 - k2 i, 1 - k3 i];

   gDP = DensityPlot[(x + y)/2, {x, 0, 1}, {y, 0, 1}, 
            ColorFunction -> green];

   Show[GraphicsArray[{{gCP, gDP}}]];

I get the beautiful red ContourPlot  gCP that I want from lines 1 thru 
3; the beautiful green DensityPlot  gDP  that I want from lines 4 thru 
6; and then the two of them together from line 7.

What puzzles me, however, is that if I replace the string "green" by 
"red" in lines 5 and 6 above, the individual plots CP and DP from lines 
1 thbru 6 still come out red and green as before --- but the two 
graphics produced by the Show[ ] command in line 7 now both come out 

The DP resulting from line 6 obviously knew it was supposed to be green 
when it was first rendered, even though its ColorFunction was 
confusingly named "red", because red[i_] had been redefined using k 
values appropriate to green in line 5.  How come it forgets all about 
this when Show time comes around?

[Email cc of replies welcomed]


come out green**.

  • Prev by Date: Re: Question
  • Next by Date: Re: question
  • Previous by thread: Re: reliability function drawing
  • Next by thread: RootSum