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

Home » Public Forums » archive » Re: Color table questions
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 table questions [message #38156 is a reply to message #38138] Fri, 20 February 2004 13:17 Go to previous messageGo to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <103cnnc4ku4pg20@corp.supernews.com>,
Michael Wallace <mwallace.removethismunge@swri.edu.invalid> wrote:

> I'm asking the question because, other than simple gradients, I haven't
> completely figured out how to make not only a good looking colorbar, but
> one that's also linear. I would have thought that someone else out
> there might also want to do this...

Here is a simple routine to change a section of the color table
between indices cmin and cmax to a blue-to-white-to-red ramp.
I use it for data where I have 'negative' regions (blue) and
'positive' regions (red). Values near zero are white.
The trick is to work in HSV space (or HLS space, if you prefer).

The rest of the color table is unchanged.

Ken Bowman



PRO BLUE_WHITE_RED, cmin, cmax

;NAME:
; BLUE_WHITE_RED
;PURPOSE:
; This procedure sets a portion of the color scale to blue-white-red.
;CATEGORY:
; Graphics and display.
;CALLING SEQUENCE:
; BLUE_WHITE_RED, cmin, cmax
;INPUT:
; cmin : minimum index of color table to use.
; cmax : maximum index of color table to use.
;KEYWORDS:
; None.
;OUTPUT:
; Changes the IDL color table.
;MODIFICATION HISTORY:
; KPB, 1997-10-01. Updated 2004-02-20.

COMPILE_OPT IDL2 ;Set compile options

nc = cmax - cmin + 1 ;Number of colors
cmid = (cmin + cmax)/2 ;Midpoint of color scale

TVLCT, r, g, b, /GET ;Get current color table
COLOR_CONVERT, r, g, b, h, s, v, /RGB_HSV ;Convert to hsv

IF(nc GT N_ELEMENTS(r)) THEN $
MESSAGE, 'Available color table of ', N_ELEMENTS(r), 'colors is insufficient for ', nc, ' colors.'

h[cmin :cmid] = 240.0 ;Lower half blue
h[cmid+1:cmax] = 0.0 ;Upper half red
s[cmin :cmid] = MAKEN(1.0, 0.0, cmid - cmin + 1) ;Fade to white at middle
s[cmid+1:cmax] = MAKEN(0.0, 1.0, cmax - cmid ) ;Fade from white at middle
v[cmin :cmax] = 1.0 ;Set the value

TVLCT, h, s, v, /HSV ;Load color scale

END
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Animations: A can or worms?
Next Topic: colorcoded text in latex

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

Current Time: Wed Oct 08 18:18:10 PDT 2025

Total time taken to generate the page: 0.00462 seconds