11.52.79 xformat

set <axis>format ( auto | <format> )
      ( horizontal | vertical | rotate <angle> )

By default, the major tick marks along axes are labelled with representations of the ordinate values at each point, each accurate to the number of significant figures specified using the set numerics sigfig command. These labels may appear as decimals, such as $3.142$, in scientific notion, as in $3\times 10^8$, or, on logarithmic axes where a base has been specified for the logarithms, using syntax such as1

set log x1 2

in a format such as $1.5\times 2^8$.

The set xformat command – together with its companions such as set yformat – is used to manually specify an explicit format for the axis labels to take, as demonstrated by the following pair of examples:

set xformat "%.2f"%(x)
set yformat "%s$^\prime$"%(y/unit(feet))

The first example specifies that values should be displayed to two decimal places along the x-axis; the second specifies that distances should be displayed in feet along the y-axis. Note that the dummy variable used to represent the represented value is x, y or z depending upon the direction of the axis, but that the dummy variable used in the set x2format command is still x. The following pair of examples both have the equivalent effect of returning the x2-axis to its default system of tick labels:

set x2format auto
set x2format "%s"%(x)

The following example specifies that ordinate values should be displayed as multiples of $\pi $:

set xformat "%s$\pi$"%(x/pi)
plot [-pi:2*pi] sin(x)

Note that where possible, Pyxplot intelligently changes the positions along axes where it places the ticks to reflect significant points in the chosen labelling system. The extent to which this is possible depends upon the format string supplied. It is generally easier when continuous-varying numerical values are substituted into strings, rather than discretely-varying values or strings.


  1. Note that the x axis must be referred to as x1 here to distinguish this statement from set log x2.