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

Home » Public Forums » archive » Re: plot, xtickname
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
Re: plot, xtickname [message #13130] Wed, 21 October 1998 00:00
Michael Werger is currently offline  Michael Werger
Messages: 34
Registered: May 1997
Member
I attach a routine which plots an array (flux vs. wavelength == spectrum)
in an coordinate system with flux vs. normalized radial velocity (where
the doppler formulae v/c = (lambda - lambda0) / lambda0 is used.

This shows how to set the xticklabels as you want to have them.

a typical call would be (dummy example now!)
IDL> x=findgen(1000)*2+5000
IDL> y=sin(x) ; just to produce any data
IDL> lambda0 = 6563.0 ; the famous rest wavelength of hydrogen-alpha
IDL> lxtitle = 'Wavelength (A)'
IDL> uxtitle = 'Radial velocity in 1000 km/s'
IDL> ytitle = 'Flux'
IDL> title = 'Spectrum of Dummy'
IDL> labels = [lxtitle,uxtitle,ytitle,title]
IDL> vplot,x,y,xrange=[6100.0,6900.0],lambda0=lambda0,label=label s

Hope this helps,

campo9729@my-dejanews.com wrote:
>
> Harald,
>
> Your suggestion assumes that I know ahead of time what my xaxis labels will
> be. I do not know this. Get_Label.pro is not a general routine. I've tried
> creating an x or y array with the values that I want and using nodata=1,
> but this creates no labels at all. This is very frustrating. I would
> appreciate any further help.
> Regards,
> Cathy
>
;+
; NAME:
; vplot
;
; PURPOSE:
; provide a simple wavelength/velocity vs. intensity plot interface
;
; CATEGORY:
; graphics, plotting
;
; CALLING SEQUENCE:
; vplot,x,y,xrange=xrange,lambda0=lambda0,label=label,test=tes t,nodata=nodata
;
; INPUTS:
; x independent wavelength axis
; y dependent flux axis
;
; KEYWORDS:
; xrange data window (optional)
; lambda0 central wavelength of velocity scale (must be specified)
; label string array: [lower x label, upper x label, y label, title]
; nodata show no data
;
; OUTPUTS:
; a plot
;
; EXAMPLE:
;
; NOTES:
; xrange overrides !x.range
; but if xrange is not specified, !x.range is required
;
; MODIFICATION HISTORY:
; 970127 Michael Werger
;
;-
pro vplot,x,y,xrange=xrange,lambda0=lambda0,label=label,test=tes t,nodata=nodata

; parameter check

case n_params() of
2: ;
else: message,'booo'
endcase

if not keyword_set(xrange) then xrange=!x.range

sx_range= !x.range
!x.range=0

; get limits

index = where(x ge xrange(0) and x le xrange(1))
xreduz = x(index)
yreduz = y(index)
x0reduz = xreduz - lambda0
v0reduz = 3e5*(x0reduz/lambda0)
if keyword_set(test) then print,min(xreduz),max(xreduz)
if keyword_set(test) then print,min(v0reduz),max(v0reduz)

; plot

if keyword_set(nodata) then nodaten = 1 else nodaten = 0

if not keyword_set(label) then begin
plot,xreduz,yreduz,xstyle=9,ystyle=1,$
nodata=nodaten,$
xtitle='Wavelength (�)',$
ytitle='norm. Flux'
plot,v0reduz/1000.,yreduz,xstyle=5,ystyle=1,$
nodata=nodaten,$
/noerase,xtick_get=xtickget
if keyword_set(test) then print,xtickget
axis,xaxis=1,$
xstyle=1,$
xtickv=xtickget,$
xtickname=string(xtickget,Format='(D4.0)'),$
xtitle='Radial velocity (10!E3!N km s!E-1!N)'
plot,xreduz,yreduz,xstyle=9,ystyle=1,$
/nodata,/noerase
endif else begin
plot,xreduz,yreduz,xstyle=9,ystyle=1,$
nodata=nodaten,$
xtitle=label(0),$
ytitle=label(2)
plot,v0reduz/1000.,yreduz,xstyle=5,ystyle=1,$
nodata=nodaten,$
/noerase,xtick_get=xtickget
if keyword_set(test) then print,xtickget
axis,xaxis=1,$
xstyle=1,$
xtickv=xtickget,$
xtickname=string(xtickget,Format='(D4.0)'),$
xtitle=label(1)
plot,xreduz,yreduz,xstyle=9,ystyle=1,$
/nodata,/noerase
endelse
!x.range=sx_range
end

--
Michael Werger ------------o
ESA ESTEC & Praesepe B.V. |
Astrophysics Division mwerger@astro.estec.esa.nl|
| Postbus 299 http://astro.estec.esa.nl |
| 2200 AG Noordwijk +31 71 565 3783 (Voice)
o------------------- The Netherlands +31 71 565 4690 (FAX)
Re: plot, xtickname [message #13131 is a reply to message #13130] Tue, 20 October 1998 00:00 Go to previous message
campo9729 is currently offline  campo9729
Messages: 2
Registered: October 1998
Junior Member
Harald,

Your suggestion assumes that I know ahead of time what my xaxis labels will
be. I do not know this. Get_Label.pro is not a general routine. I've tried
creating an x or y array with the values that I want and using nodata=1,
but this creates no labels at all. This is very frustrating. I would
appreciate any further help.
Regards,
Cathy


campo9729@my-dejanews.com wrote:
>
>> i am doing a tv command and then a plot command to create axes around
>> the image. i would like to use the plot command and exactly specify
>> the x axis tick names that i want. here is my array of xaxis names in
>> this order:
>>
>> xaxis=[0,2,4,6,20,33,40,6,9,15,25,35]
>> xaxis=string(xaxis)
>>
>> but i am unsure which keywords to use.
>> (in my case my xaxis array will be much longer, but i don't
>> even know how to do this example case.)
>
> You could use the XTICKFORMAT keyword together with the XTICKS and
> XMINOR keywords (see IDL documentation).
>
> Try the following:
>
>
;----------------------------------------------------------- -------------------
> FUNCTION Get_Label, axis, index, value
>
> xaxis=STRING([0,2,4,6,20,33,40,6,9,15,25,35])
> RETURN, xaxis[index]
>
> END
>
> WINDOW, XSIZE=400, YSIZE=400
> image = DIST(300)
> TVSCL, image, 50, 50
> PLOT, [0], XTICKS=11, XMINOR=1, XTICKFORMAT='Get_Label', $
> YTICKS=1, YMINOR=1, YTICKFORMAT='(A1)', $
> POSITION=[50,50,349,349], /NOERASE, /DEVICE
> END
> ;----------------------------------------------------------- ----------------
>
> The keyword YTICKFORMAT='(A1)' suppresses the y-axis annotation.
>
> Regards,
> Harald
>
> ------------------------------------
> Harald Jan Jeszenszky
> harald@iwf.tu-graz.ac.at
>
> Space Research Institute
> Austrian Academy of Sciences
> ------------------------------------
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Re: plot, xtickname [message #13139 is a reply to message #13131] Tue, 20 October 1998 00:00 Go to previous message
harald is currently offline  harald
Messages: 5
Registered: October 1998
Junior Member
On Mon, 19 Oct 1998 17:34:51 GMT, campo9729@my-dejanews.com wrote:

> i am doing a tv command and then a plot command to create axes around
> the image. i would like to use the plot command and exactly specify
> the x axis tick names that i want. here is my array of xaxis names in
> this order:
>
> xaxis=[0,2,4,6,20,33,40,6,9,15,25,35]
> xaxis=string(xaxis)
>
> but i am unsure which keywords to use.
> (in my case my xaxis array will be much longer, but i don't
> even know how to do this example case.)

You could use the XTICKFORMAT keyword together with the XTICKS and
XMINOR keywords (see IDL documentation).

Try the following:

;----------------------------------------------------------- ------------------------
FUNCTION Get_Label, axis, index, value

xaxis=STRING([0,2,4,6,20,33,40,6,9,15,25,35])
RETURN, xaxis[index]

END

WINDOW, XSIZE=400, YSIZE=400
image = DIST(300)
TVSCL, image, 50, 50
PLOT, [0], XTICKS=11, XMINOR=1, XTICKFORMAT='Get_Label', $
YTICKS=1, YMINOR=1, YTICKFORMAT='(A1)', $
POSITION=[50,50,349,349], /NOERASE, /DEVICE
END
;----------------------------------------------------------- -----------------------

The keyword YTICKFORMAT='(A1)' suppresses the y-axis annotation.

Regards,
Harald

------------------------------------
Harald Jan Jeszenszky
harald@iwf.tu-graz.ac.at

Space Research Institute
Austrian Academy of Sciences
------------------------------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Problems with object graphics under Linux
Next Topic: adjustimg brightness of an image

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

Current Time: Wed Oct 08 20:02:49 PDT 2025

Total time taken to generate the page: 0.43001 seconds