;------------------------------------------------------------- ;+ ; NAME: ; COLORBAR ; PURPOSE: ; Make a color bar. ; CATEGORY: ; CALLING SEQUENCE: ; cbar ; INPUTS: ; KEYWORD PARAMETERS: ; Keywords: ; VMIN=vmn Minimum value of color bar parameter (def=0). ; VMAX=vmx Maximum value of color bar parameter (def=top). ; CMIN=cmn Color that represents vmn (def=0). ; CMAX=cmx Color that represents vmx (def=top). ; where top = !d.table_size-1. ; CTICKNAME=ctn Array of color bar axis labels. ; /HORIZONTAL Colors vary horizontally (def). ; /VERTICAL Colors vary vertical. ; /BOTTOM Horizontal axis on bottom (def). ; /TOP Horizontal axis on top. ; /RIGHT Vertical axis on right (def). ; /LEFT Vertical axis on left. ; Plus all keywords accepted by PLOT. ; OUTPUTS: ; COMMON BLOCKS: ; NOTES: ; Notes: Bar is positioned using the POSITION keyword. ; To display a title use TITLE and so on. ; MODIFICATION HISTORY: ; R. Sterner, 13 Dec, 1993 ; R. Sterner, 1994 Jul 5 --- Added axis positioning. ; ; Copyright (C) 1993, Johns Hopkins University/Applied Physics Laboratory ; This software may be used, copied, or redistributed as long as it is not ; sold and this copyright notice is reproduced on each copy made. This ; routine is provided as is without any express or implied warranties ; whatsoever. Other limitations apply as described in the file disclaimer.txt. ;- ;------------------------------------------------------------- pro colorbar, vmin=vmn, vmax=vmx, cmin=cmn, cmax=cmx, horizontal=hor, $ vertical=ver, top=top, bottom=bottom, left=left, right=right, $ position=pos, color=col, title=ttl, _extra=extra, nticks=nt, $ charsize=csz, ticklen=tl, help=hlp, ctickname=ctn, thick=th, $ tcol=tcol, taper=taper if keyword_set(hlp) then begin print,' Make a color bar.' print,' cbar' print,' All arguments are keywords.' print,' Keywords:' print,' VMIN=vmn Minimum value of color bar parameter (def=0).' print,' VMAX=vmx Maximum value of color bar parameter (def=top).' print,' CMIN=cmn Color that represents vmn (def=0).' print,' CMAX=cmx Color that represents vmx (def=top).' print,' where top = !d.table_size-1.' print,' CTICKNAME=ctn Array of color bar axis labels.' print,' /HORIZONTAL Colors vary horizontally (def).' print,' /VERTICAL Colors vary vertical.' print,' /BOTTOM Horizontal axis on bottom (def).' print,' /TOP Horizontal axis on top.' print,' /RIGHT Vertical axis on right (def).' print,' /LEFT Vertical axis on left.' print,' TAPER Add taper at ends (0=none, 1=both, 2=low, 3=high) print,' Plus all keywords accepted by PLOT.' print,' Notes: Bar is positioned using the POSITION keyword.' print,' To display a title use TITLE and so on.' return endif ;------- Set defaults --------------- if n_elements(vmn) eq 0 then vmn = 0. if n_elements(vmx) eq 0 then vmx = !d.table_size-1 if n_elements(cmn) eq 0 then cmn = 0 if n_elements(cmx) eq 0 then cmx = !d.table_size-1 if n_elements(col) eq 0 then col = !p.color if n_elements(ttl) eq 0 then ttl = '' if n_elements(csz) eq 0 then csz = !p.charsize if n_elements(nt) eq 0 then nt = 0 if n_elements(tl) eq 0 then tl = -0.2 if n_elements(th) eq 0 then th = 1.0 if n_elements(tcol) eq 0 then tcol=1 mincol = tcol maxcol = cmx ;---- Set orientation dependent parameters ---------- if keyword_set(ver) then begin ; Vertical. dim = [1,256] x = [0.0,1.0] y = [vmn,vmx] ax = 2 ; Right. if keyword_set(left) then ax = 4 ; Left. if n_elements(pos) eq 0 then pos = [.4,.2,.6,.8] pos1 = pos if (keyword_set(taper)) then begin if (taper EQ 1 OR taper EQ 2) then $ pos1[1] = pos[1] + 0.1 * (pos[3] - pos[1]) if (taper EQ 1 OR taper EQ 3) then $ pos1[3] = pos[3] - 0.1 * (pos[3] - pos[1]) x1 = [pos[0],(pos[0]+pos[2])/2.0,pos[2]] y1 = [pos1[1],pos[1],pos1[1]] x2 = [pos[0],(pos[0]+pos[2])/2.0,pos[2]] y2 = [pos1[3],pos[3],pos1[3]] endif endif else begin ; Horizontal. dim = [256,1] x = [vmn,vmx] y = [0,1] ax = 1 ; Bottom. if keyword_set(top) then ax = 3 ; Top. if n_elements(pos) eq 0 then pos = [.2,.4,.8,.6] pos1 = pos if (keyword_set(taper)) then begin if (taper EQ 1 OR taper EQ 2) then $ pos1[0] = pos[0] + 0.1 * (pos[2] - pos[0]) if (taper EQ 1 OR taper EQ 3) then $ pos1[2] = pos[2] - 0.1 * (pos[2] - pos[0]) x1 = [pos1[0],pos[0],pos1[0]] y1 = [pos[1],(pos[1]+pos[3])/2.0,pos[3]] x2 = [pos1[2],pos[2],pos1[2]] y2 = [pos[1],(pos[1]+pos[3])/2.0,pos[3]] endif endelse ;----- Make bar -------------- z = reform(scalearray(maken(vmn,vmx,256),vmn,vmx,cmn,cmx+1),dim) m = where(z GT cmx,cnt) if (cnt GT 0) then z[m] = cmx ;------ Plot bar ------------- tn = [' ',' '] plot, x,y,xstyle=1,ystyle=1,/nodata,/noerase,xticks=1,xtickn=tn,$ yticks=1,ytickn=tn,xminor=1,yminor=1,pos=pos1, col=col, $ chars=csz, xran=x, yran=y, xthick=th, ythick=th imgunder, z plot, x,y,xstyle=1,ystyle=1,/nodata,/noerase,xticks=1,xtickn=tn,$ yticks=1,ytickn=tn,xminor=1,yminor=1,pos=pos1, col=col, $ chars=csz, xran=x, yran=y, xthick=th, ythick=th ;-------- Axis ------------ if n_elements(ctn) gt 0 then begin case ax of 1: axis,xaxis=0,xticklen=tl,xtitle=ttl,/xstyl,xticks=nt, $ xtickn=ctn,xminor=1,chars=csz,col=col,_extra=extra, $ xthick=th 2: axis,yaxis=1,yticklen=tl,ytitle=ttl,/ystyl,yticks=nt, $ ytickn=ctn,yminor=1,chars=csz,col=col,_extra=extra, $ ythick=th 3: axis,xaxis=1,xticklen=tl,xtitle=ttl,/xstyl,xticks=nt, $ xtickn=ctn,xminor=1,chars=csz,col=col,_extra=extra, $ xthick=th 4: axis,yaxis=0,yticklen=tl,ytitle=ttl,/ystyl,yticks=nt, $ ytickn=ctn,yminor=1,chars=csz,col=col,_extra=extra, $ ythick=th endcase endif else begin case ax of 1: axis,xaxis=0,xticklen=tl,xtitle=ttl,/xstyl,xticks=nt, $ xminor=1,chars=csz,col=col,_extra=extra,xthick=th 2: axis,yaxis=1,yticklen=tl,ytitle=ttl,/ystyl,yticks=nt, $ yminor=1,chars=csz,col=col,_extra=extra,ythick=th 3: axis,xaxis=1,xticklen=tl,xtitle=ttl,/xstyl,xticks=nt, $ xminor=1,chars=csz,col=col,_extra=extra,xthick=th 4: axis,yaxis=0,yticklen=tl,ytitle=ttl,/ystyl,yticks=nt, $ yminor=1,chars=csz,col=col,_extra=extra,ythick=th endcase endelse ;------ Plot taper and each end ------------- if (keyword_set(taper)) then begin if (taper EQ 1 OR taper EQ 2) then begin polyfill,x1,y1,color=mincol,/norm plots,x1,y1,color=col,/norm endif if (taper EQ 1 OR taper EQ 3) then begin polyfill,x2,y2,color=maxcol,/norm plots,x2,y2,color=col,/norm endif endif end