Does IDL have a generic procedure to output a colorbar on a contour plot?
I found a procedure on the web, and it works great when device is set to
the display but it doesn't look the same when device is set to PS. Here's
my procedure to read in a data file, call a procedure to calculate the
wavelet transform, and plot the results:
************************************************************ ********************
READCOL, 'oct30.dat', time1, data ; reads in the data file
wave = WAVELET(data,0.0155,PERIOD=period,COI=coi,/PAD,SIGNIF=signif ,SCALE=scale)
freq = 6/(scale)
LOADCT,39
!P.font = 0 ;i want hardware fonts
mydevice = !D.NAME
set_plot, 'PS'
device, filename = 'oct30.ps', /COLOR, /inches
CONTOUR,ABS(wave)^2,time1,freq,xtickformat='xticks',$
XSTYLE=1,XTITLE='Time',YTITLE='Frequency (Hz)', $
TITLE='Oct30 Wavelet Power Spectrum',YRANGE=[MIN(freq), 10], $
pos = [0.2, 0.2, 0.9, 0.9], /YLOG, YSTYLE=1, NLEVELS=25,/FILL
dispbar,250,10,200,5,/Border ; display the color bar, see below
device, /close
set_plot, mydevice
************************************************************ ********************
Here's the procedure to display the colorbar:
************************************************************ ********************
pro dispbar,cbllx,cblly,cbx,cby,Border=Border
;+
; NAME:
; DISPBAR
; DESCRIPTION:
; This procedure creates and displays a color bar on the screen.
; CALLING SEQUENCE:
; DISPBAR,cbllx,cblly,cbx,cby,Border=Border,Vertical=Vertical
; INPUT:
; CBLLX Color Bar Lower Left hand X coordinate
; CBLLY Color Bar Lower left hand Y coordinate
; CBX Color Bar X length
; CBY Color Bar Y height
; OUTPUT:
; Screen output only. All passed variables remain unchanged.
; OPTIONAL FLAGS:
; BORDER Puts a white (BLACK in PS) border around the color bar.
; HISTORY:
; 30-MAY-90 Version 1 written by Eric W. Deutsch
; 24-AUG-91 Added /Border Keyword (E. Deutsch)
;-
if (n_params(0) lt 4) then begin
print,'Call: IDL> DISPBAR,lwrlft_X,lwrlft_Y,X_length,Y_height,[/Border]'
print,'e.g.: IDL> dispbar,120,30,100,10,/Border'
return
endif
if (n_elements(Border) eq 0) then Border=0
if (cby eq 0) or (cbx eq 0) then return
bar=byte(indgen(cbx)*(!d.n_colors*1./cbx<255))
for i=0,cby-1 do tv,bar,cbllx,cblly+i
if (Border eq 1) then plots,[cbllx,cbllx+cbx,cbllx+cbx,cbllx,cbllx], $
[cblly,cblly,cblly+cby-1,cblly+cby-1,cblly],/device
return
end
************************************************************ ********************
Any help appreciated.
Rick McDaniel
|