Working with Specific Colors in IDL [message #14569] |
Mon, 08 March 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Martin Schultz (mgs@io.harvard.edu) writes in an article
on another subject:
> it would certainly be
> helpful to have predefined drawing colors as default (instead of or in
> addition to) the grey scale color table which first has to be
> overwritten (and this seems to be a running themke on this newsgroup
> too). Best would be to have a standard set of named colors so that you
> could write plot,color=black and it would work no matter whether you
> have < 256 colors or 16M. This shouldn't be hard to implement for true
> color systems
Several weeks ago now Liam Gumley offered a color table in
this newsgroup that represented the 16 colors offered in
the McIDAS color map. I liked those colors so much that I
added them to my GETCOLOR program. At the same time, I
updated GETCOLOR to make it a little easier to use.
Those of you who have used GETCOLOR know that the
purpose of it is to be able to ask for a color by "name".
But I added a second positional parameter to it so that
you can now pass it an index number where the color
should be loaded. For example, suppose you want to
draw a plot in yellow. You can do this:
yellow = GetColor("yellow", 10)
Plot, Findgen(11), Color=yellow
I tend to use it like this. Suppose I want a gray
background, green axes, and yellow data colors:
; Load the colors.
yellow = GetColor("yellow", !D.Table_Size-4)
green = GetColor("green", !D.Table_Size-3)
gray = GetColor("gray", !D.Table_Size-2)
; Draw the plot.
Plot, Findgen(11), Color=green, Background=gray
OPlot, Findgen(11), Color=yellow
The code above will work on an 8-bit display or on
a 24-bit display with DECOMPOSED color turned OFF.
If you want to work with DECOMPOSED color turned ON,
it is even more straightforward:
Plot, Findgen(11), Color=GetColor("yellow", /True)
It is still possible to get the color triple back that
represents a particular color. Just don't pass the index
parameter:
triple = GetColor("yellow")
Print, triple
While this doesn't address all of Martin's issues, it does
make it a little easier to work with 16 pretty nice colors. :-)
You can download GETCOLOR at this URL:
http://www.dfanning.com/programs/getcolor.pro
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|