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

Home » Public Forums » archive » Re: setting default background color, etc
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: setting default background color, etc [message #8900] Wed, 14 May 1997 00:00
Andy Loughe is currently offline  Andy Loughe
Messages: 174
Registered: November 1995
Senior Member
Melissa Nischan wrote:
>
> Hi All,
>
> I am very new to IDL, and have what I believe should be a basic
> question (but I couldn't find anything in the FAQ about it): when I start
> IDL and plot something, I always get white on a black background. I
> discovered that if I set !p.background I can change that, but I was
> wondering how do I set the default background to be something other than
> black? It's a pain to have to set it each time. (I use IDL on a
> UNIX machine)
>
> thanks,
> Melissa
> nischan@ll.mit.edu



Put

!p.background = preferred_color_index

into a startup file that is automatically run when entering idl.

In Unix, IDL_STARTUP contains the name of this startup file.

--
Andrew F. Loughe |
afl@cdc.noaa.gov
University of Colorado, CIRES Box 449 |
http://cdc.noaa.gov/~afl
Boulder, CO 80309-0449 | phn:(303)492-0707
fax:(303)497-7013
------------------------------------------------------------ ---------------
"I do not feel obliged to believe that the same God who has endowed us
with
sense, reason, and intellect has intended us to forego their use."
-Galileo
Re: setting default background color, etc [message #8901 is a reply to message #8900] Wed, 14 May 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Melissa Nischan writes:

> I am very new to IDL, and have what I believe should be a basic
> question (but I couldn't find anything in the FAQ about it): when I start
> IDL and plot something, I always get white on a black background. I
> discovered that if I set !p.background I can change that, but I was
> wondering how do I set the default background to be something other than
> black? It's a pain to have to set it each time. (I use IDL on a
> UNIX machine)

Hi Melissa,

By default, IDL sets the background color to color index 0. Thus,
to change the background color, you need to load some other
color into this index. For example, you could load (heaven forbid!)
a yellow color in this index like this:

IDL> TVLCT, 255, 255, 0, 0

You could even do this in an IDL startup file.

The problem with this approach is that every time you load
a new color table you are likely to write over this index.
What I usually do is save about four or five colors at the
top of my color table for "drawing colors". Then I make sure
I use these colors for plotting, etc. And I make sure I don't
write over them when I change color tables.

For example, here are three drawing colors (charcoal, yellow,
and green, loaded into the last three elements of the color
table. You might do this in an IDL startup file:

; Find out how many colors you have.

Window, /Pixmap, /Free, XSize=10, YSize=10
WDelete, !D.Window
ncolors = !D.N_Colors

; Data colors--leave top three colors alone.

dataColors = ncolors - 3

; Load "drawing" colors (charcoal, yellow, green).

TVLCT, [120, 255, 0], [120, 255, 255], [120, 0, 0], dataColors
backgroundColor = dataColors
plotColor = dataColors + 1
oplotColor = dataColors + 2
!P.Background = backgroundColor
!P.Color = plotColor

Now, you can just draw a plot, like this:

data = Findgen(11)
Plot, data

Or, you can specify the colors specifically, like this:

Plot, data, Color=plotColor, Background=backgroundColor
OPlot, Reverse(data), Color=oplotColor

When you load a new color table, be sure you only load the
data colors, and don't write over your drawing colors. Do
something like this:

XLoadCT, NColors=datacolors

There are a lot of color tips like this on my Coyote's Guide
to IDL Programming web page. You will also find programs
(e.g. GETCOLOR, CHGCOLOR, XCOLORS, etc.) that will help you work
with colors in IDL.

Good luck!

David

----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: netCDF and PV-Wave 6.01
Next Topic: setting default background color, etc

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

Current Time: Sat Oct 11 07:43:52 PDT 2025

Total time taken to generate the page: 0.72015 seconds