13. Module unit

With the unit module PyX makes available classes and functions for the specification and manipulation of lengths. As usual, lengths consist of a number together with a measurement unit, e.g., [1]cm, [50]points, [0.42]inch. In addition, lengths in PyX are composed of the five types ``true'', ``user'', ``visual'', ``width'', and ``TEX'', e.g., [1]user cm, [50]true points, $(0.42\ \mathrm{visual} + 0.2\
\mathrm{width})$ inch. As their names indicate, they serve different purposes. True lengths are not scalable and are mainly used for return values of PyX functions. The other length types can be rescaled by the user and differ with respect to the type of object they are applied to:

user length:
used for lengths of graphical objects like positions etc.
visual length:
used for sizes of visual elements, like arrows, graph symbols, axis ticks, etc.
width length:
used for line widths
TEX length:
used for all TEX and LATEX output

When not specified otherwise, all types of lengths are interpreted in terms of a default unit, which, by default, is [1]cm. You may change this default unit by using the module level function

set( uscale=None, vscale=None, wscale=None, xscale=None, defaultunit=None)
When uscale, vscale, wscale, or xscale is not None, the corresponding scaling factor(s) is redefined to the given number. When defaultunit is not None, the default unit is set to the given value, which has to be one of "cm", "mm", "inch", or "pt".

For instance, if you only want thicker lines for a publication version of your figure, you can just rescale all width lengths using

unit.set(wscale=2)
Or suppose, you are used to specify length in imperial units. In this, admittedly rather unfortunate case, just use
unit.set(defaultunit="inch")
at the beginning of your program.


Subsections