Kinda of a silly question, but I've been banging head against the wall
for the past two nights. I am trying to figure out how I can make my
own colour gradient, analogous to Rainbow, AplineColors, &c.
Is there any standard framework around trying to create your own?
Further, say I wanted one of the preexisting ones, but scaled
exponentially, or set a particular value to bright yellow (to
highlight that specific result). I used to use IDL quite a bit, and
made use of these kinds of manipulations frequently.
Any ideas or references? I keep finding myself doing the same old loop
in the Documentation Center, from ColorData, to ColorFunction, and so
on, and so on.....
Cheers,
t.
the gradients are in the form of ColorFunctions. As almost everything
these are normal mathematica expressions that you can handle just like
any other expression. You can look at the FullForm of these to see the
data they contain:
ColorData["Rainbow"] // FullForm
What you will see is that it basically contains a pure function which
encapculates a Blend. With that information, adoptions and constructions
of own color functions should be simple:
mycolorfun=Function[Blend[{Red,Green,Blue},#]]
this will change an existing colorfunction:
newfun = ColorData["Rainbow"] /.
RGBColor[0.513417`, 0.72992`, 0.440682`] -> RGBColor[1, 1, 1]
since there is additional information used for the formatting that is
not updated within the ColorFunction-Object, you might want to extract
the pure functions and work with only those:
newfun = ColorData["Rainbow"] /.
RGBColor[0.513417`, 0.72992`, 0.440682`] -> RGBColor[1, 1, 1]
hth,
albert
Blend[{Subscript[col, 1],Subscript[col, 2],Subscript[col, 3],\
\[Ellipsis]},x]
linearly interpolates between colors Subscript[col, i] as x varies \
from 0 to 1.
Hi Tyler,
Not sure whether this is what you are looking for, but the following
thread, "Gradient fill as Background for Plot", might be of some help:
http://groups.google.com/group/comp.soft-sys.math.mathematica/msg/10df9c064cfc1039
HTH (and that you won't have to hurt yourself anymore :-)]
-- Jean-Marc
Some examples:
cbar[cfun_] :=
DensityPlot[x, {x, 0, 1}, {y, 0, 1}, AspectRatio -> 1/7,
Frame -> False, ColorFunction -> cfun]
A built-in gradient:
cbar["Rainbow"]
Custom gradient:
cbar[Blend[{Red, Green, Blue}, #] &]
Built-in gradient transformed with a power function:
cbar[ColorData["Rainbow"][#^4] &]
Cheers,
t.
PS - I never thought to try FullForm on ColorData...nice trick :)
Cheers,
t.
PS - I never thought to try FullForm on ColorData...nice trick :)
On Oct 3, 6:42 am, Szabolcs Horv=E1t <szhor...@gmail.com> wrote:
Cheers,
t.
PS - I never thought to try FullForm on ColorData...nice trick :)
On Oct 3, 6:42 am, Szabolcs Horv=E1t <szhor...@gmail.com> wrote: