[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window Background

Eric Kihn (ekihn@ngdc.noaa.gov) writes:

> 	Since I got such a great response to my last post I thought I'd try one=
> =20
> more time.  Thanks to JD I got the code running but now the=20
> behaviour on Windows and Linux is different. On the Linux side my plot=20
> window comes up with a white background, on the Windows side a black one=
> .
> Same code and version of IDL 5.3.  Since I need the white BG I tried=20
> !P.BACKGROUND =3D 255 on windows but no change.

What you really should be doing here is setting the background
color value to the index of the white color in the color
vectors you are using. You loaded a white color into index
0. So your code should look like this:

  TVLCT, r, g, b
  !P.Background = 0

*Then* if you don't get what you are looking for,
you might have other problems.

I tend to prefer to ask for colors by name. I have
recently upgraded some of the color tools on my
web page to recognize 88 different colors by name.
(I even added the capability of adding your own
color names and values as a color value file.) The
advantage of this method is that it *always* gives
me the correct color on all machines and in any
color decomposition state (if I am using IDL 5.2 or
higher where I can tell what the color decomposition
state is).

For example, if I want to create background, axes, and
data plotting colors, I would write my code like this:

   axisColor = FSC_COLOR("Green", !D.Table_Size-2)
   backColor = FSC_COLOR("Charcoal", !D.Table_Size-3)
   dataColor = FSC_COLOR("Yellow", !D.Table_Size-4)
   Plot, Findgen(11), Color=axisColor, Background=backColor, /NoData
   OPlot, Findgen(11), Color=dataColor

This works for all machines in any color decomposition space.

In addition to FSC_COLOR, the new program PICKCOLORNAME will
allow the user to interactively select a new color name for
use with FSC_COLOR:

   ; Set new data color.

   datacolor = PickColorName("Yellow")
   data = Reverse(Findgen(11))
   OPLOT, data, Color=FSC_COLOR(datacolor, !D.Table_Size-4)

To see a list of the 88 colors available, type this:

  IDL> Print, FSC_COLOR(/Names)

Or, to see an interactive list of the color names and
the actual colors:

   IDL> color = PickColorName('dark gray')

You can find the programs here:



David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155