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

Home » Public Forums » archive » Re: Colors in PLOT with IDL
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 in PLOT with IDL [message #39554 is a reply to message #39553] Tue, 25 May 2004 04:11 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Andreas Ernst writes:

> what is the argument for PLOT and OPLOT to plot
> a colored graph in IDL? The argument linestyle is
> not sufficient, my plot looks still very ugly with
> different line styles.

Color is a pretty complicated subject. You have
to worry about whether your device is 8-bit or
24-bit, whether color decomposition is turned on
or off, how many colors can physically be loaded
in the color table, etc., etc. It can drive you
crazy if you let it.

That's why I use a color program, FSC_COLOR, that
makes a lot of these decisions for me and lets me
create a plot in a device independent way. The
following short program will look identical on
your display screen, sent to a PostScript file,
run in the Z-graphics buffer, etc.

You can find FSC_COLOR here:

http://www.dfanning.com/programs/fsc_color.pro

And, of course, you can find a LOT of information about
color, generally, on my web page. :-)

PRO DrawingColorTest

; Create drawing colors.
axisColor = FSC_Color('navy', !D.Table_Size-2)
background = FSC_Color('ivory', !D.Table_Size-3)
dataColor = FSC_Color('indian red', !D.Table_Size-4)
fillColor = FSC_Color('dodger blue', !D.Table_Size-5)
outlineColor = FSC_Color('dark green', !D.Table_Size-6)

; Create data for a plot. Fill the region from x=20 to x=45.
x = Findgen(101)
y = 4 * Sin(x * !DtoR) / Exp( (x-15) / 25.)
lowVal = 20
highVal = 45

; Draw the plot.
lowY = 4 * Sin(lowVal * !DtoR) / Exp( (lowVal-15) / 25.)
highY = 4 * Sin(highVal * !DtoR) / Exp( (highVal-15) / 25.)
indices = Value_Locate(x, [lowVal, highVal])
low = indices[0]
high = indices[1]

IF x(low) LT lowVal THEN low = low + 1
IF x(high) GT highVal THEN high = high - 1

xpoly = [lowVal, lowVal, x[low:high], highVal, highVal]
ypoly = [!Y.CRange[0], lowY, y[low:high], highY, !Y.CRange[0]]
PolyFill, [0,0,1,1,0], [0,1,1,0,0], Color=background, /Normal
PolyFill, xpoly, ypoly, Color=fillColor
PlotS, xpoly, ypoly, Color=outlineColor, Thick=2
Plot, x, y, Color=axisColor, /NoData, /NoErase
OPlot, x, y, Color=dataColor, Thick=3

END

To run this program at the IDL command line:

IDL> Window
IDL> DrawingColorTest

To run this program in the PostScript device:

IDL> thisDevice = !D.Name
IDL> Set_Plot, 'PS'
IDL> Device, Color=1, Bits=8
IDL> DrawingColorTest
IDL> Device, /Close
IDL> Set_Plot, thisDevice


Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Colors in PLOT with IDL
Next Topic: Re: Smoothing Data with optimal wiener filter

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

Current Time: Sun Oct 12 14:52:41 PDT 2025

Total time taken to generate the page: 1.60264 seconds