Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Documentation on (Color) Blend

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111277] Re: Documentation on (Color) Blend
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Mon, 26 Jul 2010 06:36:31 -0400 (EDT)

Hi,

to interpolate between the colors red RGBColor[{1,0,0}], green, and
white you really dont need the Blend function. You have 4 values for the
colors

{{0, 1, 0}, {1, 1, 1}, {1, 1, 1}, {1, 0, 0}}

Just interpolate the points and build a function giving you the colors
in range:

f[x_] = Through[(ListInterpolation[#, {{0, 1}}] & /@ 
      Transpose[{{0, 1, 0}, {1, 1, 1}, {1, 1, 1}, {1, 0, 0}}])[x]];
cols[start_, end_, n_] := 
 Table[RGBColor[f[i]], {i, start, end, (end - start)/(n - 1)}]

with that you can do

Graphics[Transpose[{cols[0, 1, 20], Table[Disk[{i, 0}], {i, 20}]}], 
 Background -> Gray]

or just get Colors from White to Red:

In[28]:= cols[0.5, 1, 5]

Out[28]= {RGBColor[{1.0625, 1.0625, 1.125}], 
 RGBColor[{1.02051, 1.03418, 1.05469}], 
 RGBColor[{0.960938, 0.882812, 0.84375}], 
 RGBColor[{0.936523, 0.555664, 0.492187}], RGBColor[{1., 0., 0.}]}

Cheers
Patrick


On Sun, 2010-07-25 at 19:48 -0500, Ryan Gorka wrote:
> Patrick and David:
> 
> Thanks for the help. Once I generate something I like, such as
> 
> DensityPlot[x, {x, -1, 1}, {y, 0, 1}, FrameTicks -> None,
>  ColorFunction -> (Blend[{{0, Green}, {0.4, White}, {0.6, White}, {1,
>       Red}}, #] &)]
> 
> Do you have any suggestions for the best way (or at least a reasonable
> way) to pick a range of x colors from that? I'll probably start with a
> linear sampling, although non-linear samplings also interest me---my
> main goal is to avoid injecting 'lie factor' via coloring in my
> diagrams, so any wisdom you can impart is appreciated. BTW, are there
> any Edward Tufte fans in here?
> 
> I suppose for now I can just use //InputForm, Part[] and go digging
> for RGB values. 
> 
> -RG
> 
> On Sun, Jul 25, 2010 at 7:04 PM, Patrick Scheibe
> <pscheibe at trm.uni-leipzig.de> wrote:
>         Hi,
>         
>         you don't need the (buggy) sample with the Table. Just read a
>         bit in the
>         Blend documentation and eventually do something like
>         
>         DensityPlot[x, {x, -1, 1}, {y, 0, 1}, FrameTicks -> None,
>          ColorFunction -> (Blend[{{0, Green}, {0.4, White}, {0.6,
>         White}, {1,
>               Red}}, #] &)]
>         
>         Cheers
>         Patrick
>         
>         
>         On Sun, 2010-07-25 at 01:58 -0400, telefunkenvf14 wrote:
>         > Group:
>         >
>         > The documentation on Blend[], in the "Possible Issues"
>         section,
>         > contains the following example.
>         >
>         >  ----------------
>         > In plot functions, use ColorFunctionScaling to control
>         global scaling
>         > of variables:
>         >
>         > Table[DensityPlot[x, {x, -2, 3}, {y, 0, 1}, FrameTicks ->
>         None,
>         >   ColorFunction -> (Blend[{Red, Green}, #] &),
>         >   ColorFunctionScaling -> t], {t, {False, True}}]
>         >  ----------------
>         >
>         > I noticed that when I evaluate the code, the original output
>         is not
>         > reproduced. On my machine the new plots look exactly the
>         same.
>         > (Windows 7, 64-bit, Mathematica 7.0.1)
>         >
>         > Can someone offer a fix? My goal is to generate a Green to
>         White to
>         > Red spectrum with a 'fuzzier' center; eventually I'll use
>         this for
>         > coloring a map.
>         >
>         > -RG
>         >
>         
>         
> 



  • Prev by Date: Re: A question on plot3D
  • Next by Date: Re: Need to align data from sublists to Union of dates
  • Previous by thread: Re: Documentation on (Color) Blend
  • Next by thread: Linking my fortran subroutines with Mathematica