1.11.2 Text labels

Text labels may be placed on plots using the set label command. As with all textual labels in Pyxplot, these are rendered in latex:

set label 1 'Hello World' at 0,0

As in the previous section, the number 1 is a reference number, which allows the label to be removed by either of the following two commands:

set nolabel 1
unset label 1

The positional coordinates for the text label, placed after the at keyword, can be specified in any of the coordinate systems described for arrows above. As above, either two or three coordinates may be supplied. A rotation angle may optionally be specified after the keyword rotate, to rotate text counter-clockwise by a given angle, measured in degrees. For example, the following would produce upward-running text:

set label 1 'Hello World' at axis3 3.0, axis4 2.7 rotate 90

A color can also be specified, if desired, using the with color modifier. For example, the following would produce a green label at the origin:

set label 2 'This label is green' at 0, 0 with color green

The size of the text can be set using the with fontsize modifier:

set label 3 'A Big Blue Label' at 0,0 with col blue fontsize 4

Alternatively, it may be set globally using the set fontsize command. This applies not only to the set label command, but also to plot titles, axis labels, keys, etc. The value supplied should be a multiplicative factor greater than zero; a value of 2 would cause text to be rendered at twice its normal size, and a value of 0.5 would cause text to be rendered at half its normal size.

The set textcolor command can be used to globally set the color of all text output, and applies to all of the text that the set fontsize command does. It is especially useful when producing plots to be embedded in presentation slideshows, where bright text on a dark background may be desired. It should be followed either by an integer, to set a color from the present palette, or by a color name. A list of the recognised color names can be found in Section . For example:

set textcolor 2
set textcolor blue

By default, each label’s specified position corresponds to its bottom left corner. This alignment may be changed with the set texthalign and set textvalign commands. The former takes the options left, center or right, and the latter takes the options bottom, center or top, for example:

set texthalign right
set textvalign top

The wavelengths of the spectral lines of atomic hydrogen are given by the Rydberg formula,

  \[  \frac{1}{\lambda } = R_\mathrm {H}\left(\frac{1}{n^2}-\frac{1}{m^2}\right),  \]    

where

$$λ$ is wavelength, $R_H$ is the Rydberg constant, predefined in Pyxplot as the variable {\tt phy\_ Ry}, and {\tt n} and {\tt m} are positive non-zero integers such that {\tt m>n}. The first few series are called the Lyman series ({\tt n}$=1$), the Balmer series ({\tt n}$=2$), the Paschen series ({\tt n}$=3$) and the Brackett series ({\tt n}$=4$). Within each series, the lines are given Greek letter designations – $α$ for {\tt m}$=${\tt n}$+1$, $β$ for {\tt m}$=${\tt n}$+2$, and so forth. \\ \hspace{8mm}In the following example, we produce a diagram of the lines in the first four series, drawing the first~ 20 lines within each. At the bottom of the diagram, we overlay indications of the wavelengths of ten color filters commonly used by astronomers (data taken from Binney \&  Merrifield, {\it Galactic Astronomy}, Princeton, 1998). \vspace{3mm}\\ \noindent \input{examples/tex/ex_ hlines_1.tex} \vspace{3mm}\\ \noindent \begin{center}  \includegraphics[width=11cm]{examples/eps/ex_ hlines} \end{center}  $


In this example, we use Pyxplot to plot a map of Australia, using a coastal outline obtained from http://www.maproom.psu.edu/dcw/. We use the set label command to label the states and major cities. The files ex_map_1.dat.gz and ex_map_2.dat can be found in the Pyxplot installation tarball in the directory doc/examples/.

set size 20 ratio (45-10)/(154-112)*cos(25*unit(deg))
set xrange [112:154]
set yrange [-45:-10]

# We want a plot without axes or key
set nokey
set axis x invisible
set axis y invisible

# Labels for the states

set label 1 r’{$$$large~ $$sf~ $$slshape~ Western~ Australia\} ’~ 117,~ -28$
set label 2 r’{$$$large~ $$sf~ $$slshape~ South~ Australia\} ’~ 130,~ -29.5$
set label 3 r’{$$$large~ $$sf~ $$slshape~ Northern~ Territory\} ’~ 129.5,~ -20.5$
set label 4 r’{$$$large~ $$sf~ $$slshape~ Queensland\} ’~ 141,-24$
set label 5 r’{$$$large~ $$sf~ $$slshape~ New~ South~ Wales\} ’~ 142,-32.5$
set label 6 r’{$$$large~ $$sf~ $$slshape~ Victoria\} ’~ 139,-41$
set arrow 6 from 141,-40 to 142, -37 with nohead
set label 7 r’{$$$large~ $$sf~ $$slshape~ Tasmania\} ’~ 149,-42$
set arrow 7 from 149, -41.5 to 146.5, -41.75 with nohead
set label 8 r’{$$$large~ $$sf~ $$slshape~ Capital~ Territory\} ’~ 151,-37$
set arrow 8 from 151, -36.25 to 149, -36 with nohead

# Labels for the cities
set label 10 r’{$$$sf~ Perth\} ’~ 116.5,~ -32.4$
set label 11 r’{$$$sf~ Adelaide\} ’~ 136,~ -38$
set arrow 11 from 137.5,-37.2 to 138.601, -34.929
set label 12 r’{$$$sf~ Darwin\} ’~ 131,~ -13.5$
set label 13 r’{$$$sf~ Brisbane\} ’~ 149,~ -27.5$
set label 14 r’{$$$sf~ Sydney\} ’~ 151.5,~ -34.5$
set label 15 r’{$$$sf~ Melbourne\} ’~ 143,~ -37.3$
set label 16 r’{$$$sf~ Hobart\} ’~ 147.5,~ -44.25$
set label 17 r’{$$$sf~ Canberra\} ’~ 145,~ -35.25$

# A big label saying "Australia"
set label 20 r’{$$$Huge~ $$sf~ $$slshape~ Australia\} ’~ 117,-42$

# Plot the coastline and cities
plot ’map_1.dat.gz’ every ::1 with lines, $$$$
     ’map_2.dat’ with points pointtype 17 pointsize 2

\includegraphics[width=\textwidth ]{examples/eps/ex_map}