MathGroup Archive 2004

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

Search the Archive

Re: on ColorFunction and combined images?


Hi,

when you combine the plots, the ColorFunctionScaling option
is removed and the colors computed incorrect and this cause your
error.  You should do something like

mycf[x_] := RGBColor[0, 0, Mod[(x - 350)/20, 1]]
pic1 = DensityPlot[350 + 20*x^2, {x, 0, 1}, {y, 0, 1}, ColorFunction ->
mycf, 
    Mesh -> False]
pic2 = Plot[x^2, {x, 0, 1}];
Show[pic1, pic2];

Regards
  Jens

Sampo Smolander wrote:
> 
> Intro:
> 
> If I want to combine, say, a density field plot and an overlaid
> curve on it, it is rather easy:
> 
> pic1 = DensityPlot[x^2, {x, 0, 1}, {y, 0, 1}, Mesh -> False]
> pic2 = Plot[x^2, {x, 0, 1}]
> Show[pic1, pic2]
> 
> My Case:
> 
> But say that I am plotting a densify field that that describes, just for
> an example, some carbon dioxide concentrations for which a natural scale
> (in the air outdoors) is something like 350...370 rather than 0...1.
> 
> I can tell DensityPlot to feed the raw concentration values
> to the ColorFunction, and I can provide it my own ColorFunction:
> 
> mycf[x_] := RGBColor[0, 0, (x - 350)/20]
> pic1 = DensityPlot[350 + 20*x^2, {x, 0, 1}, {y, 0, 1},
>   ColorFunctionScaling -> False, ColorFunction -> mycf, Mesh -> False]
> pic2 = Plot[x^2, {x, 0, 1}]
> Show[pic1, pic2]
> 
> The Problem:
> 
> There is no problem in drawing the pic1, but then when I try to
> combine pic1 and pic2 with that Show, I get an error message:
> "Argument in RGBColor[0, 0, -17.5] is not a real number between 0 and 1."
> 
> It apparently happens so that with Show, the pic1 is redrawn and (some
> of?) the options that I gave in the original DensityPlot command are not
> used anymore.
> 
> Is there a way around this problem?
> How can I overlay other graphs with densityplots for which I have used my
> own colorfunctions?
> 
> I think of the following: I could manually scale every function, that I
> attempt to plot, to give out values only in the range 0...1. Then
> I guess everything should work okay. But an easier way?
> 
> --
> Sampo Smolander ............... http://www.cs.helsinki.fi/u/ssmoland/
> Division of Atmospheric Sciences ............. University of Helsinki


  • Prev by Date: Re: bug in IntegerPart ?
  • Next by Date: Re: Numerically computing partial derivatives
  • Previous by thread: RE: on ColorFunction and combined images?
  • Next by thread: Re: strange problems with Random