pro color_bar,ncolors,offset,black,dmin,dmax,label,type,posbar,loc ;----------------------------------------------------------------------------------- ; Routine draws a color bar ; ; Input: ; ncolors....# of colors used ; offset.....offset for start of color table (byte, 0B works) ; black......number corresponding to black in color table ; dmin.......axis data minimum ; dmax.......axis data maximum ; label......character string for axis label ; type.......axis type, 0=linear, 1=log ; posbar.....position for color bar, plot coordinates, fltarr(4), e.g. [x1,y1,x2,y2] ; loc........1 = draw the bar horizontaly on the top of plot ; 2 = draw the bar verticaly to the left of plot (default) ; ; Source: Mark Hervig ;----------------------------------------------------------------------------------- if (loc ne 1 and loc ne 2) then loc=2 ;- draw color bar bar = byte(indgen(ncolors,2) mod ncolors)+offset !p.region = posbar !x.margin = [0,0] !y.margin = [0,0] plot,[0,1],[0,1],/nodata,xstyle=4,ystyle=4,/noerase if loc eq 2 then begin tv,transpose(bar),posbar(0),posbar(1),/normal,xsize=posbar(2)-posbar(0),ysize=posbar(3)-posbar(1) axis,yaxis=1,yran=[dmin,dmax],ytitle=label,ytype=type,/ystyle,/noerase,ticklen=-0.30,color=black endif if loc eq 1 then begin tv,bar,posbar(0),posbar(1),/normal,xsize=posbar(2)-posbar(0),ysize=posbar(3)-posbar(1) axis,xaxis=1,xran=[dmin,dmax],xtitle=label,xtype=type,/xstyle,/noerase,ticklen=-0.30,color=black endif return end