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
plot f(x)
generates two columns of data, with values of in the first column,
plot parametric f(t)
generates only one column of data.
Spirograph patterns.
Spirograph patterns are produced when a pen is tethered to the end of a rod which rotates at some angular speed
which are simply the sum of two circular motions with angular velocities inversely proportional to their radii. The complexity of the resulting spirograph pattern depends upon how rapidly the rods return to their starting configuration; if the two chosen angular speeds for the rods have a large lowest common multiple, then a highly complicated pattern will result. In the example below, we pick a ratio of |
||||||||||||
r1 = 1.5 |
||||||||||||
![]() |
||||||||||||
Other ratios of r1:r2 such as |