[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PLOT question

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

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

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
t0 = 0  ; starting time of first (or any) period

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 van Gorkom            gorkom@rijnh.nl
FOM-Instituut voor Plasmafysica Rijnhuizen