MathGroup Archive 2004

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

Search the Archive

on ColorFunction and combined images?

  • To: mathgroup at
  • Subject: [mg47930] on ColorFunction and combined images?
  • From: Sampo Smolander <sampo.smolander+newsnspam at>
  • Date: Fri, 30 Apr 2004 19:27:13 -0400 (EDT)
  • Organization: University of Helsinki
  • Sender: owner-wri-mathgroup at


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 ...............
Division of Atmospheric Sciences ............. University of Helsinki

  • Prev by Date: Re: labeling curves on a plot
  • Next by Date: Re: bug in IntegerPart ?
  • Previous by thread: RE : 34.123*89 = 3036.95 (3036.947)