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 9.4. 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, where 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, Galactic Astronomy, Princeton, 1998). set numeric display latex # Draw lines of first four series of hydrogen lines # Label astronomical photometric colors # Draw a marker for the Lyman limit # Finally produce plot 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)) # We want a plot without axes or key # Labels for the states # Labels for the cities # A big label saying "Australia" # Plot the coastline and cities
is wavelength,
is the Rydberg constant, predefined in Pyxplot as the variable phy_Ry, and n and m are positive non-zero integers such that m>n. The first few series are called the Lyman series (n
), the Balmer series (n
), the Paschen series (n
) and the Brackett series (n
). Within each series, the lines are given Greek letter designations –
for m
n
,
for m
n
, and so forth.
set width 20
set size ratio 0.4
set numerics sf 4
set log x
set x1label "Wavelength"
set x2label "Frequency" ; set unit of frequency Hz
set x3label "Photon Energy" ; set unit of energy eV
set axis x2 linked x1 using phy.c/x
set axis x3 linked x2 using phy.h*x
set noytics ; set nomytics
an=2
n=1
foreach SeriesName in ["Ly","Ba","Pa","Br"]
{
for m=n+1 to n+21
{
wl = 1/(phy.Ry*(1/n**2-1/m**2))
set arrow an from wl,0.3 to wl,0.6 with nohead col n
if (m-n==1) { ; GreekLetter = r"alpha" ; }
if (m-n==2) { ; GreekLetter = r"beta" ; }
if (m-n==3) { ; GreekLetter = r"gamma" ; }
if (m-n4)
{
set label an r"parbox{5cm}{
footnotesize
center{
%s-$%s$newline $%d
to%d$
newline %s
newline}}"
%(SeriesName,GreekLetter,m,n,wl) at wl,0.55+0.2*(m-n)
hal center val center
}
an = an+1
}
n=n+1
}
foreach datum i,name,wl_c,wl_w in "–" using
1:"%s"%($2):($3*unit(nm)):($4*unit(nm))
{
arry = 0.12+0.1*(i%2) # Vertical positions for arrows
laby = 0.07+0.1*(i%2) # Vertical positions for labels
x0 = (wl_c-wl_w/2) # Shortward end of passband
x1 = wl_c # Centre of passband
x2 = (wl_c+wl_w/2) # Longward end of passband
set arrow an from x0,arry to x2,arry with nohead
set label an name at x1,laby hal center val center
an = an+1
}
1 U 365 66
2 B 445 94
3 V 551 88
4 R 658 138
5 I 806 149
6 J 1220 213
7 H 1630 307
8 K 2190 390
9 L 3450 472
10 M 4750 460
END
ll = 91.1267*unit(nm)
set arrow 1 from ll,0.12 to ll,0.22
set label 1 "Lyman Limit: %s"%(ll) at 95*unit(nm),0.17
hal left val center
plot [80*unit(nm):5500*unit(nm)][0:1.25]
set xrange [112:154]
set yrange [-45:-10]
set nokey
set axis x invisible
set axis y invisible
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
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
set label 20 r’{Huge
sf
slshape Australia}’ 117,-42
plot ’map_1.dat.gz’ every ::1 with lines,
’map_2.dat’ with points pointtype 17 pointsize 2