Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: on ColorFunction and combined images?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47972] Re: on ColorFunction and combined images?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 4 May 2004 01:08:52 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <c6up48$b6n$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

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