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

Home » Public Forums » archive » Color tables
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: Color tables [message #18066 is a reply to message #17997] Tue, 23 November 1999 00:00 Go to previous messageGo to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
David Fanning wrote:
>
> 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.
>


Why not use two different colormaps altogether...

im=randomu(sd,100,100)-.2 ; some fake data

;; Load red into upper half of color map, and blue into the lower half
loadct,3,BOTTOM=!D.N_COLORS/2 & loadct,1,NCOLORS=!D.N_COLORS/2

;; Scale all positives into the upper half
dpos=bytscl(im,MIN=0.,TOP=!D.N_COLORS/2-1)+!D.N_COLORS/2
;; Scale all negatives into the lower half, in reverse!
dneg=!D.N_COLORS/2-1-bytscl(im,MAX=0.,TOP=!D.N_COLORS/2-1)
;; Put them together
d=dpos*(im ge 0.)+dneg*(im lt 0.)

I've loaded red into the top half, blue into the bottom half. The positives are
scaled into the top half, and the negatives are scaled in reverse into the
bottom half (so that more negative values would be brighter blue). Obviously
there are many different possibilities based on this basic scheme. You can also
create your own custom colormap, but often it's easiest to scale the data
instead.

Good luck,

JD

--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-6263
304 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Color tables
Next Topic: un-Mask?/PolyOutlineV?

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

Current Time: Fri Oct 10 15:55:38 PDT 2025

Total time taken to generate the page: 1.59729 seconds