pro color_ba,bins,min_value,max_value,ps_color_option ;============================================================================= ; Written by S Mayor in December 1995 to put a color ; bar on the image. Designed to handle any type of ; color table you throw at it. Color table can be ; even or odd number of bins. ; ; ps_color_option added 6/15/97 by SDM. Necessary for halftone images. ; 1=no color (halftone), 2=color ; ;============================================================================= sx=700 ; width of the window in pixels sy=512 ; depth of the window in pixels ;============================================================================= ; *** From here on out, do all graphics in NORMAL coordinates (0-1) *** ;============================================================================= x_center=.5 ; x center of the color bar y_center=.85 ; y center of the color bar if (bins lt 20) then begin dx=20./sx ; width of a single color box endif else begin dx=10./sx ; width of a single color box endelse dy=20./sy ; height of a single color box cby0=y_center-(dy/2.) ; bottom position of the color bar cby1=y_center+(dy/2.) ; top position of the color bar start=(1.-(bins*dx))/2. ; left position of the color bar ; Regardless of the data type, the color bar will be drawn ; centered and so that can be done now. first = 0 last = bins-1 for bin=first,last do begin cbx0=start+((bin-first)*dx) cbx1=start+(((bin-first)+1)*dx) if (ps_color_option eq 2) then begin polyfill,[cbx0,cbx1,cbx1,cbx0],[cby0,cby0,cby1,cby1],color=bin,/normal endif else begin polyfill,[cbx0,cbx1,cbx1,cbx0],[cby0,cby0,cby1,cby1],color=(bin*255)/bins,/normal endelse endfor plots,[start,start+bins*dx],[cby0,cby0],/normal plots,[start,start+bins*dx],[cby1,cby1],/normal plots,[start,start],[cby0,cby1],/normal plots,[start+bins*dx,start+bins*dx],[cby0,cby1],/normal ; And now comes the hard part... drawing the tick marks according to ; the max and min data range. ;if ((bins mod 2) eq 0) then begin ; EVEN number of bins start=start+dx ; x position of left most tick mark finish=start+((bins-2)*dx) ; x position of right most tick mark ;endif else begin ; ODD number of bins ; start=start+(dx/2.) ; x position of left most tick mark ; finish=start+((bins-1)*dx) ; x position of right most tick mark ;endelse cby2 = cby1 + .009 cby3 = cby2 + .015 cby4 = cby3 + .009 plots,[start,finish],[cby2,cby2],/normal ; draw horizontal line note = ' ' if (max_value gt 1000.) or ((max_value gt 0) and (max_value le .1)) then begin find_mag,max_value,mag ; find the magnitude of the max value max_val = max_value / (10^mag) min_val = min_value / (10^mag) note = 'x10!e'+strtrim(string(fix(mag)),2)+'!n' endif else begin max_val = max_value min_val = min_value endelse delta = max_val - min_val ; what are the range of data?? if (delta lt 10) then begin if ((delta*10. mod 5) eq 0) then begin divisions = 5 endif else begin divisions = 6 endelse endif else begin if ((delta mod 5) eq 0) then begin divisions = 5 endif else begin divisions = 6 endelse endelse if (delta eq 52) then divisions = 4 if (delta eq 50) then divisions = 10 if (delta eq 48) then divisions = 8 if (delta eq 40) then divisions = 8 if (delta eq 36) then divisions = 6 if (delta eq 32) then divisions = 8 if (delta eq 30) then divisions = 6 if (delta eq 28) then divisions = 4 if (delta eq 24) then divisions = 8 if (delta eq 20) then divisions = 5 if (delta eq 16) then divisions = 8 if (delta eq 08) then divisions = 8 if (delta eq 06) then divisions = 6 ;divisions = 6 step_value = delta/divisions dx = (finish-start)/divisions tick_count = 0. for i = min_val, max_val, step_value do begin x = start+(tick_count*dx) ; x pos of tick mark plots,[x,x],[cby2,cby3],/normal ; draw tick mark if ((i mod 1) eq 0.) then begin value = string(strtrim(long(float(i)),2)) endif else begin value = strtrim(string(i,format='(f10.1)'),2) endelse xyouts,x,cby4,value,alignment=.5,/normal ; draw the label tick_count = tick_count + 1. ; next tick endfor x = x + (strlen(value)/2.)*(float(!d.x_ch_size)/float(!d.x_size)) xyouts,x,cby4,note,/normal return end