RE: on ColorFunction and combined images?

*To*: mathgroup at smc.vnet.net*Subject*: [mg47941] RE: [mg47930] on ColorFunction and combined images?*From*: "David Park" <djmp at earthlink.net>*Date*: Sun, 2 May 2004 04:50:35 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Sampo, Extending my earlier reply, we can make a fix. Mathematica errors in dropping the ColorFunctionScaling option when converting DensityGraphics to Graphics. We can repair it by adding it back into the generated Raster statement. Using regular Mathematica plotting, we could use... 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[Graphics[{First[Graphics[pic1]] /. Raster[args__] :> Raster[args, ColorFunctionScaling -> False], First[pic2]}], AspectRatio -> Automatic, Frame -> True]; I consider that to be somewhat convoluted and I first made the fix by using the DrawGraphics package from my web site below. The whole initial objective of DrawGraphics was to make it easy to combine plots of various types, without having to worry about side plots. Also, since it deals directly with the primitive graphics, it makes it easy to manipulate those graphics. I also make a little lighter color function. Draw statements replace Plot statements and extract the primitive graphics. Needs["DrawGraphics`DrawingMaster`"] mycf[x_] := ColorMix[Blue, White][(x - 350)/20] Draw2D[ {DensityDraw[350 + 20 x^2, {x, 0, 1}, {y, 0, 1}, ColorFunction -> mycf, Mesh -> False] /. Raster[args__] :> Raster[args, ColorFunctionScaling -> False], Draw[x^2, {x, 0, 1}]}, AspectRatio -> Automatic, Frame -> True]; David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Sampo Smolander [mailto:sampo.smolander+newsnspam at helsinki.fi] To: mathgroup at smc.vnet.net 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

**RE: Union & Select for removing duplicates in a list**

**Re: bug in IntegerPart ?**

**RE: on ColorFunction and combined images?**

**Re: on ColorFunction and combined images?**