comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: colors and plot direct graphics function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: colors and plot direct graphics function [message #82449] Fri, 14 December 2012 18:28 Go to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Friday, December 14, 2012 4:31:50 PM UTC-7, bing999 wrote:
> Hi,
>
>
>
> I switched from idl 7 to 8.2 recently, and start using direct graphics
>
> for plotting purposes.
>
>
>
> To plot in colors in idl 7, I used to do:
>
> loadct,39
>
> plot,x,y,color=250
>
> for a red line.
>
>
>
> With direct graphics I can do:
>
>
>
> p=plot(x,y,AXIS_STYLE=0,$
>
> XRANGE=[0,30],YRANGE=[0,30],color='red')
>
>
>
> But is there a way to load a color table and use a single number value
>
> (e.g. 250 for red) for colors instead of a string with the plot
>
> function?
>
>
>
> I find it convenient to use that when you want to overplot many curves
>
> of different colors in a for loop for instance.
>
>
>
> I couldn't find this tip in the IDL help...
>
>
>
> Thanks!

Hi bing999,

There are a couple of different ways. If you want all the colors to come from the same color table, then you could use rgb_table and vert_colors:

p = plot(randomu(seed,100), rgb_table=39, vert_colors=240)

If you just wanted to be able to choose colors using an index, you could use the !color system variable, like this:

for i=1,10 do p = plot(randomu(seed,100), color=!color.(i), /overplot)

Either way will work fine. Probably the first way gives you the most control, since you can pick say every 20th color from a color table.

Just as an aside, be sure to check out the new Color Brewer color tables that we added to IDL 8.2.1:
http://www.exelisvis.com/docs/LoadingDefaultColorTables.html

Cheers,
Chris
ExelisVIS
[Message index]
 
Read Message
Read Message
Previous Topic: HASH with case insensitive keys versus a new DICT class
Next Topic: Sparse matrix algorithms

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 06:39:27 PDT 2025

Total time taken to generate the page: 1.04500 seconds