Re: Colors in Function Graphics? [message #77745] |
Tue, 20 September 2011 11:36 |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
On Sep 20, 10:30 am, Dick Jackson <d...@d-jackson.com> wrote:
> On Sep 20, 9:33 am, David Fanning <n...@dfanning.com> wrote:
>
>> wlandsman writes:
>>> I assume it is
>
>>> IDL> help,/str,!color
>
>> Ah, I tried this:
>
>> IDL> Print, !Color
>
>> Should have known better. Thanks!
>
> And possibly more convenient:
>
> IDL> Print, Tag_Names(!Color)
I see the !Color structure, with colour names as tag names, as less
than ideal. To get at the colour triples, you have to use a FOR loop
and dig into Advanced Structure Usage:
IDL> rgb=Bytarr(3, n_tags(!color))
IDL> for i=0,n_tags(!color)-1 do rgb[0,i]=(!color).(i)
IDL> tv,/true,rebin(rgb,[3,n_tags(!color)*4,50],/Sample) ; Show
swatches
To be more useful, it should have been initialized something like:
!ColorHandy = [{NAME: 'ALICE_BLUE', RGB: [240B, 248B, 255B]}, {...}]
Then you could get !ColorHandy.name for all the names, !ColorHandy.rgb
for the [3, 147] array.
I've written a routine to make a !ColorHandy variable (suitable for
inclusion in your startup file, or IDL's kernel, depending on your
influence :-)... you're welcome to it, all rights absolved.
PRO InitColorHandy
; Makes system variable !ColorHandy, an array of structures, from
information
; extracted from !Color.
; - N_Elements(!ColorHandy) is the number of colors
; - !ColorHandy.name is StrArr(nColors) containing all the names
; - !ColorHandy.rgb is Bytarr(3, nColors) the RGB array.
nColors = N_Tags(!Color)
rgb = BytArr(3, nColors)
FOR colorI=0, nColors-1 DO rgb[0, colorI] = (!Color).(colorI)
DefSysV, '!COLORHANDY', Replicate({Name: '', RGB: BytArr(3)}, nColors)
!ColorHandy.name = Tag_Names(!Color)
!ColorHandy.rgb = rgb
END
Once this is run, the following is possible in one line:
IDL> tv,/true,rebin(!colorhandy.rgb,[3,n_elements(!colorhandy)*4, 50],/
Sample) ; Show swatches
Cheers,
-Dick
Dick Jackson Software Consulting
Victoria, BC, Canada
www.d-jackson.com
|
|
|
Re: Colors in Function Graphics? [message #77747 is a reply to message #77745] |
Tue, 20 September 2011 10:30  |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
On Sep 20, 9:33 am, David Fanning <n...@dfanning.com> wrote:
> wlandsman writes:
>> I assume it is
>
>> IDL> help,/str,!color
>
> Ah, I tried this:
>
> IDL> Print, !Color
>
> Should have known better. Thanks!
And possibly more convenient:
IDL> Print, Tag_Names(!Color)
|
|
|
Re: Colors in Function Graphics? [message #77748 is a reply to message #77747] |
Tue, 20 September 2011 09:33  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Sep 20, 1:21 pm, David Fanning <n...@dfanning.com> wrote:
> Has anyone discovered a list of the possible color names
> you can use in function graphics?
There is a "Formatting IDL Graphics Symbols and Lines" page in the
help. Not that it is easy to find. I go there by the link in "Using
IDL Graphics", where I get either by a search or by the page of one of
the functions.
|
|
|
Re: Colors in Function Graphics? [message #77749 is a reply to message #77748] |
Tue, 20 September 2011 09:33  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
wlandsman writes:
> I assume it is
>
> IDL> help,/str,!color
Ah, I tried this:
IDL> Print, !Color
Should have known better. Thanks!
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|