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

Re: Color tables



Karsten Thiel (thiel@ph4.physik.uni-goettingen.de) writes:

> I'm facing a problem concerning the color tables. I would like to
> display a large array with some negativ
> values. Till now I'm doing this with TVSCL, but the information where
> the values are negativ is very important for me. So how are the
> pre-defined color tables defined? Which table is the best for my
> problem?

Well, Karsten, I hate to tell you, but NONE of the color
tables are best for your problem. And, in fact, if
colors *are* important to you (and they must be or you wouldn't
be writing) then you had better ditch TVSCL too. :-) 

Let me give you an example. Suppose you have data in
a variable named "array". And suppose you would like to
see the positive values of the data in the Red Temperature
color table. But you would like to see the negative values
of your data in a yellow color.

Then you could do something like this. Let's suppose
you have 200 colors to use. Let's use 199 of them
for the Red Temperature color scale:

   LoadCT, 3, NColors=199

Let's make the 200th color yellow:

   TVLCT, 255, 255, 0, 199

Now, lets scale the data so that the positive
values lie in the data range 0 to 198. In other
words, they will be displayed in the Red Temperature
colors:

  scaledData = BytScl(array, Min=0, Top=198)

Let's find out where our negative values are:

   negvalues = Where( array LT 0, count)

Make the negative values yellow:

   IF count GT 0 THEN scaledData[negvalues] = 199B

Now, have a look! :-)

   TV, scaledData

It is always better to have some *plan* for using colors
than to just take whatever IDL seems to offer. 

Cheers,

David

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