Labels can be added to the axes of a plot, and a title put at the top. Labels should be placed between either single (’) or double (") quotes, as in the following example script:
set xlabel "Horizontal axis" set ylabel "Vertical axis" set title 'A plot with labelled axes' plot
These labels and title – in fact, all text labels which are ever produced by PyXPlot – are rendered using the LaTeX typesetting system, and so any LaTeX commands can be used to produce custom formatting. This allows great flexibility, but means that care needs to be taken to escape any of LaTeX’s reserved characters – i.e. & % # { } $ _
or
.
Because of the use of quotes to delimit text labels, special care needs to be taken when apostrophe and quote characters are used. The following command would raise an error, because the apostrophe would be interpreted as marking the end of the text label:
|
set xlabel ’My plot’s X axis’ |
The following would achieve the desired effect:
|
set xlabel "My plot’s X axis" |
To make it possible to render LaTeX strings containing both single and double quote characters – for example, the string J"org’s Data, which puts a German umlaut on the letter o as well as having a possessive apostrophe – PyXPlot recognises the backslash character to be an escape character when followed by either ’ or ". A double backslash (
) represents a literal backslash. These are the only cases in which PyXPlot considers
an escape character. To render the example string above, one would type:
|
set xlabel "J ![]() |
In this example, three backslashes are required. The first pair produce the LaTeX escape character used to produce the umlaut; the second is a PyXPlot escape character, used so that the " character is not interpreted as delimiting the string.
The pre-defined texify() function may provide some assistance in generating LaTeX labels: it takes either an algebraic expression, or a string in quotes, and produces a LaTeX representation of it, as in the following examples:
pyxplot> a=50
pyxplot> print texify("A %d% increase"%(a))
A 50% increase
pyxplot> print texify(sqrt(x**2+1))
$displaystyle
sqrt{x
{2}+1}$
Having set labels and titles, they may be removed thus:
set xlabel '' set ylabel '' set title ''
These are two other ways of removing the title from a plot:
set notitle unset title
The unset command may be followed by almost any word that can follow the set command, such as xlabel or title, to return that setting to its default configuration. The reset command restores all configurable parameters to their default states.