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

Home » Public Forums » archive » Re: PLOT question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: PLOT question [message #22964 is a reply to message #22954] Thu, 21 December 2000 06:05 Go to previous messageGo to previous message
Jaco van Gorkom is currently offline  Jaco van Gorkom
Messages: 97
Registered: November 2000
Member
Stuart Colley wrote:
> What I want to do is swap time for phase angle, so the phase is
> somewhere between 0 - 2pi, but the problem is that the phase angle
> repeats, so what I was looking for on the axis was something
> like:
>
> y value |
> |
> | x x
> | x x x x x
> ________|__________________x_____________________x__________ _
> time | 0 pi/2 pi 3pi/2 0 pi/2 pi 3pi/2 0 etc...
>
> |
> end of first cycle, start of second
>
> What I'll probably do is use xtickv and xtickname to set the ticks, since
> as far as I can tell, you MUST 'plot, t, y' to get the plot right,
> 'plot, phase, y' results in the data being merged together and only one
> cycle being plotted.
>
> The reason I sent the first post - I was wondering if there was an easier
> way than xtickv/xtickname since it can't automatically choose the tick
> values like PLOT can, and isn't so flexible when I'm trying to write a
> general purpose routine.


The XTICKFORMAT mechanism as proposed by Dave should give you the
periodic phase angle tick values, if you plug in the logic by Craig:

FUNCTION PHASE_ANGLE, axis, index, t
phase = (t-t0)/period
phase = phase - floor(phase)
; this phase angle goes from 0 to 1, you want 0 - 2pi:
phase = 2*!PI*phase
RETURN, STRING(phase)
END
..
PLOT, t, y, XTICKFORMAT='PHASE_ANGLE'

Now PLOT will automatically choose "nice" tick values based on the
original time values, e.g. 1 s, 2 s, ... You would like "nice" values in
phase angle (pi, 2pi, ..), so I would plot as a function of t/period
(actually the total phase angle), just to get the tick marks at nice
locations:

FUNCTION PHASE_ANGLE, axis, index, totalphase
phase = totalphase - floor(totalphase)
; this phase angle goes from 0 to 1, you want 0 - 2pi:
phase = 2 * !pi * phase
RETURN, (FORMAT_AXIS_VALUES(phase))[0]
END
..
t0 = 0 ; starting time of first (or any) period
PLOT, (t-t0)/period, y, XTICKFORMAT='PHASE_ANGLE'

One important thing here: you need to make sure that IDL uses at least
two tick marks per period, or else these nice periodic tick values will
look just like a ordinary series of zeroes. (for this, set the XTICKS
keyword if necessary)

I used FORMAT_AXIS_VALUES to get "nice" formatting of the strings. If
you *really* want "3pi/2" at your tick mark instead of 4.71 , then that
should not be too difficult to code into the PHASE_ANGLE function.
Better left as an exercise to the reader...

Jaco

------------------------------
Jaco van Gorkom gorkom@rijnh.nl
FOM-Instituut voor Plasmafysica Rijnhuizen
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: temporary() pitfall
Next Topic: PV-WAVE

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

Current Time: Sat Oct 11 00:36:22 PDT 2025

Total time taken to generate the page: 1.12028 seconds