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

Home » Public Forums » archive » Colorbar with Color levels different than ticklevels
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Colorbar with Color levels different than ticklevels [message #47346] Tue, 07 February 2006 11:26 Go to previous message
newbie16 is currently offline  newbie16
Messages: 11
Registered: December 2004
Junior Member
Hi Everyone:

Like the subject heading suggests, I am trying to have a colour bar
inserted with a smooth transistion of colours (about 60) from the min
to max values. However, I only want the tickmarks to occur evenly
spaced on ten levels. I must be missing something simple here, but for
the life of me I can't figure it out....

Changing divisions makes a mess.
I can get a colour bar with only ten colours fine, but doesn't show
what I need.

Hmmm....

Any help is greatly appreciated.

Cheers,

Tyler

Below is the relevant code I am using:

; Must define the levels used for contours
nlev = 10 ; Total number of contours
lev = nlev - 2 ; For the contours which are plotted
; -2 b/c MAX and MIN are not plotted
cont_lev = lev + 1 ; For the colour bar "tickmarks"
; cont_lev = the number of INTERVALS

; Label all values except the max & min using vector of 1's
label_tmp = replicate(0,lev) ; change 0 to 1 for labels
g_labels = [0, label_tmp, 0]

; Create vector for levels
grv_tot = abs(grv_max) + abs(grv_min) ; b/c range (+) to (-)
grv_int = grv_tot/(cont_lev)
grv_lev = fltarr(nlev,/no)
grv_lev = indgen(nlev)*grv_int + grv_min

; Test that the contour levels are correct
print, '--------------------------------------------'
print, 'The minimum gravity value is:', grv_min
print, 'The maximum gravity value is:', grv_max
print, ''
print,'The contour intervals are:'
for j = 0L,9L do begin
print, grv_lev(j), g_labels(j)
endfor
print, '--------------------------------------------'


; Now must define num_colours for the shading between contours
nc_lev = 60 ; The number of gravity contours
num_colours = nc_lev - 1 ; The number of colour intervals
col_int = (abs(grv_max) + abs(grv_min)) / (num_colours)
col_lev = findgen(nc_lev) * col_int + grv_min

bott = 35 ; Starting colour value out of 255
c_colours = findgen(nc_lev) * 220/nc_lev + bott

; load the colour table (rainbow here)
loadct, 13

; Plot the gravity colours using c_colours and col_lev
contour, NEW_GRAVITY, NEW_X_ARRAY, NEW_Y_ARRAY,$
levels = col_lev, c_colors=c_colours, $
/FILL, /OVERPLOT

; Overplot the ten contours using g_lables and grv_lev
contour, NEW_GRAVITY, NEW_X_ARRAY, NEW_Y_ARRAY,$
levels = grv_lev, c_labels=g_labels, c_colors=1,$
/OVERPLOT

; Place colourbar below the figure
colorbar, ncolors=num_colours,title='microgals',$
position=[0.1, 0.1, 0.9, 0.14], divisions=cont_lev, $
range=[min(grv),max(grv)], FORMAT='(F6.1)'
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: PIP website temporarily offline
Next Topic: Re: The plot including another plot

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

Current Time: Sat Oct 11 11:25:43 PDT 2025

Total time taken to generate the page: 0.79876 seconds