8.6 Plotting parametric functions
Parametric functions are functions expressed in forms such as
where separate expressions are supplied for the ordinate and abscissa values as a function of some free parameter . The above example is a parametric representation of a circle of radius . Before Pyxplot can usefully plot parametric functions, it is generally necessary to stipulate the range of values of over which the function should be sampled. This may be done using the set trange command, as in the example
set trange [unit(0*rad):unit(2*pi*rad)]
or in the plot command itself. By default, values in the range are used. Note that the set trange command differs from other commands for setting axis ranges in that auto-scaling is not an allowed behaviour; an explicit range must be specified for .
Having set an appropriate range for , parametric functions may be plotted by placing the keyword parametric before the list of functions to be plotted, as in the following simple example which plots a circle:
set trange [unit(0*rev):unit(1*rev)] plot parametric sin(t):cos(t)
Optionally, a range for can be specified on a plot-by-plot basis immediately after the keyword parametric, and thus the effect above could also be achieved using:
plot parametric [unit(0*rev):unit(1*rev)] sin(t):cos(t)
The only difference between parametric function plotting and ordinary function plotting – other than the change of dummy variable from x to t – is that one fewer column of data is generated. Thus, whilst
generates two columns of data, with values of in the first column,
plot parametric f(t)
generates only one column of data.