comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » colorbar help
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
colorbar help [message #10005] Sun, 28 September 1997 00:00
rickeym is currently offline  rickeym
Messages: 6
Registered: September 1997
Junior Member
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
Re: colorbar help [message #10006 is a reply to message #10005] Sun, 28 September 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Rick McDaniel writes:

> 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.

There are various colorbar routines around on the web. I have
one (called COLORBAR) on my web page that is specifically
designed to work the same on the display and in PostScript
output.

You might have a look at some of the Perfect PostScript
articles there as well. Many things can cause your PostScript
output to look different from your display output. The articles
will show you how to sort it all out and produce pretty much
WYSIWYG output.

Cheers,

David

----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Widget Builder problems
Next Topic: Re: White background Help!

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 09:18:37 PDT 2025

Total time taken to generate the page: 0.16224 seconds