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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: colors and plot direct graphics function [message #82449] Fri, 14 December 2012 18:28
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
Re: colors and plot direct graphics function [message #82451 is a reply to message #82449] Fri, 14 December 2012 15:57 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
bing999 writes:

> 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...

It appears you have actually switched to function graphics,
which use the object graphics system, not the direct graphics
system.

If you wanted to stay with direct graphics, and still
have nearly all the advantages of a modern graphics
system, you could try Coyote Graphics:

http://www.idlcoyote.com/graphics_tips/coyote_graphics.php

With Coyote Graphics, you would do this to get an equivalent plot:

LoadCT, 39
cgPlot, cgDemoData(1), Color='250', XStyle=5, YStyle=5, /Window

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Wed Oct 08 18:50:33 PDT 2025

Total time taken to generate the page: 0.08438 seconds