RE: Re: ColorFunction for ListPlot3D, ListContourPlot or ListDensityPlot ?
- To: mathgroup at smc.vnet.net
- Subject: [mg29084] RE: [mg29048] Re: ColorFunction for ListPlot3D, ListContourPlot or ListDensityPlot ?
- From: "David Park" <djmp at earthlink.net>
- Date: Sun, 27 May 2001 18:04:49 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
John, I think it is a great idea to always load the Graphics`Colors` package. But my routine doesn't really work quite right with your example. As first presented, the routine assumes that the colors are both RGBColors. Here is a modified routine which does some checking on the heads of the colors, and also clips z so it is always in the domain 0 to 1. ColorMix[color1_, color2_][z_] /; Head[color1] === Head[color2] := Module[{c1, c2, head, z2}, head = Head[color1]; z2 = Max[0, Min[1, z]]; c1 = List @@ color1; c2 = List @@ color2; head @@ ((1 - z2)c1 + z2 c2)] Then, either of these works. blend = ColorMix[CMYKColor[0, 1, .8, 0], CMYKColor[1, 0, .8, 0]]; blend = ColorMix[BurntSienna, PaleGreen]; Plot3D[Sin[x + 3*y - Random[]], {x, 0, 4}, {y, 0, 3}, ColorFunction -> blend, PlotPoints -> 31, ImageSize -> 450] I don't think Mathematica gives a direct way to convert one type of color specification to another, say CMYKColor to RGBColor, such that they could be combined in a routine like ColorMix. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > From: John Jowett [mailto:John.Jowett at cern.ch] To: mathgroup at smc.vnet.net > > David, > It may be worth remarking that your function is even more useful > (without modification!) if you first load the standard package > > <<Graphics`Colors` > > Then you can mix ways of specifying colours to your heart's content, e.g., > > blend =ColorMix[BurntSienna,CMYKColor[1,..8,0]] > > Plot3D[Sin[x+3 y-Random[]],{x,0,4},{y,0,3},ColorFunction->blend] > > John Jowett > > "David Park" <djmp at earthlink.net> wrote in message > news:oplP6.3625$8I3.14298 at ralph.vnet.net... > > Joerg, > > > > Here is a ColorMix function for blending two colors. (I think that Bob > > Hanlon had a similar routine posted a few days ago.) > > > > ColorMix[color1_, color2_][z_] := > > Module[{c1, c2}, > > c1 = List @@ color1; > > c2 = List @@ color2; > > RGBColor @@ ((1 - z)c1 + z c2)] > > > > Here, I make a contour plot that shades from brown to green. I > picked the > > colors off the color selector in the menu. > > > > ContourPlot[Sin[x*y], {x, -Pi/2, Pi/2}, > > {y, -Pi/2, Pi/2}, PlotPoints -> 30, Contours -> 10, > > ContourLines -> False, ColorFunction -> > > ColorMix[RGBColor[0.867201, 0.660166, 0.312505], > > RGBColor[0.265629, 0.398444, 0.101564]]]; > > > > David Park > > djmp at earthlink.net > > http://home.earthlink.net/~djmp/ > > > > > >