2.8 Setting Axis Ranges

In Section 2.2, the set xlabel configuration command was previously introduced for placing text labels on axes. In this section, the configuration of axes is extended to setting their ranges.

By default, PyXPlot automatically scales axes to some sensible range which contains all of the plotted data. However, it is also possible for the user to override this and set his own range. This can be done directly from the plot command, for example:

plot [-1:1][-2:2] sin(x)

The ranges are specified immediately after the plot statement, with the syntax [minimum:maximum].An alternative valid syntax is to replace the colon with the word ‘to’: [minimum to maximum]. The first specified range applies to the $x$-axis, and the second to the $y$-axis.As will be discussed in Section 3.3.1, if further ranges are specified, they apply to the $x2$-axis, then the $y2$-axis, and so forth. Any of the values can be omitted, for example:

plot [:][-2:2] sin(x)

would only set a range on the $y$-axis.

Alternatively, ranges can be set before the plot statement, using the set xrange statement, for example:

set xrange [-2:2]
set y2range [a:b]

Having done so, a range may subsequently be turned off, and an axis returned to its default autoscaling behaviour, using the set autoscale command, which takes a list of axes to which it is to apply. If no list is supplied, then the command is applied to all axes.

set autoscale x y
set autoscale

Axes can be set to have logarithmic scales using the set logscale command, which also takes a list of axes to which it should apply. Its converse is set nologscale:

set logscale
set nologscale y x x2

Further discussion of the configuration of axes can be found in Section 3.3.1.