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 
Switch to threaded view of this topic Create a new topic Submit Reply
Colorbar with Color levels different than ticklevels [message #47346] Tue, 07 February 2006 11:26 Go to next 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)'
Re: Colorbar with Color levels different than ticklevels [message #47439 is a reply to message #47346] Tue, 07 February 2006 13:40 Go to previous message
newbie16 is currently offline  newbie16
Messages: 11
Registered: December 2004
Junior Member
Thanks for the advice (and the book which arrived last week!). I've
switched the bottom value to 1, so I now have a colour vector from
1--255 of 60 elements instead of from 35--255 as before. I am only
getting 7 Tickmarks for the moment, but the plot finally looks like I
was hoping INCLUDING the scaled colour bar!

Thanks again,

Tyler
Re: Colorbar with Color levels different than ticklevels [message #47442 is a reply to message #47346] Tue, 07 February 2006 12:03 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
newbie16@hotmail.com writes:

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

Humm. Probably because you have a weird way of specifying your
colors. :-)

http://www.dfanning.com/color_tips/cbarcolors.html

This works perfectly for me.

LoadCT, 13, NColors=60, Bottom=35
Colorbar, NColors=60, Bottom=35, Divisions=10

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Sun Oct 12 00:50:12 PDT 2025

Total time taken to generate the page: 0.08065 seconds