PRO tvcb,image,f,varname,unname,forma,LOG=log ; ; Displays the image with the color bar below it. ; INPUT: image = 2D array of a certain variable ; varname (string) = name of the variable ; unname (string) = unit of the variable ; forma (string) = format string, default is '(F7.2)'. ; OUTPUT: f = image with colorbar and annotation (byte) ; KEYWORD: /log - if set, the image is expected to be in ; a logarithmic (alog10) scale and the colorbar as well. ; The annotated values correspond to the linear scale. ; on_error,1 si=size(image) mi=min(image) ma=max(image) if si(0) ne 2 then message,'TVCB: Image must be a 2D array' if n_params() lt 5 then forma='(F7.2)' if n_params() lt 4 then unname='' if n_params() lt 3 then varname='' ; Background array f f=fltarr(si(1),si(2)+40) ; 40 pix for colorbar and annotation f=f+ma ; to have a white background ; Colorbar array b ;---------------------------------------------------------------------- space=30 ; 30-pix space in front and behind the colorbar ;---------------------------------------------------------------------- xb=si(1)-2*space b=fltarr(xb,15) ; 15-pix high colorbar b1=findgen(xb)*(ma-mi)/float(xb)+mi ; linear scaling m1=b1(xb/3) ; middle values m2=b1(2*xb/3) if keyword_set(log) then begin mil=10^mi ; min & max in original values mal=10^ma b1=findgen(xb)*(mal-mil)/float(xb)+mil ; linear scaling m1=b1(xb/3) ; middle values m2=b1(2*xb/3) b1=alog10(b1) ; logarithmic scaling endif for i=1,13 do b(*,i)=b1 b(*,0)=mi ; edges and bars of colorbar b(*,14)=mi b(xb/3,*)=mi b(2*xb/3,*)=mi b(xb-1,*)=mi ; Composing f(*,40:*)=image f(space:space+xb-1,21:35)=b window,2,xs=si(1),ys=si(2)+40 tvscl,f ; Annotation xyouts,2,22,varname,charsiz=1.5,col=0,/device xyouts,space+xb+4,22,unname,charsiz=1.5,col=0,/device if keyword_set(log) then begin mi=mil ma=mal endif smi=strtrim(string(mi,FORMAT=forma),2) sm1=strtrim(string(m1,FORMAT=forma),2) sm2=strtrim(string(m2,FORMAT=forma),2) sma=strtrim(string(ma,FORMAT=forma),2) xyouts,space-10,6,smi,charsiz=1.2,col=0,/device xyouts,space+xb/3-10,6,sm1,charsiz=1.2,col=0,/device xyouts,space+2*xb/3-10,6,sm2,charsiz=1.2,col=0,/device xyouts,space+xb-20,6,sma,charsiz=1.2,col=0,/device f=tvrd() END