# PSLEGEND

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXAMPLES
WINDOWS REMARKS
SEE ALSO

## NAME

pslegend − To plot a map legend

## SYNOPSIS

pslegend textfile −D[x]lon/lat/width/height/just −J parameters −R west/east/south/north[r] [ −C dx/dy ] [ −F ] [ −G fill ] [ −K ] [ −L spacing ] [ −O ] [ −P ] [ −S[script] ] [ −U[just/dx/dy/][c|label] ] [ −V ] [ −X[a|c|r][x-shift[u]] ] [ −c copies ] [ −Y[a|c|r][y-shift[u]] ]

## DESCRIPTION

pslegend will make legends that can be overlaid on maps. It reads specific legend-related information from an input file [or stdin]. Because all the elements of the legend can already be created with other tools (psxy, pstext) we use those tools by creating a batch job of commands that are executed to make the final PostScript overlay. Because of this process, the option exists to just output the script which can then be fine-tuned manually. Unless otherwise noted, annotations will be made using the annotation font and size in effect.
textfile

This file contains instruction for the layout of items in the legend. Each legend item is described by a unique record. All records begin with a unique character that is common to all records of the same kind. The order of the legend items is implied by the order of the records. Ten different record types are recognized, and the syntax for each of these records are presented below:

# Comment records

Records starting with # and blank lines are skipped.

B cptname offset height [ optional arguments ]

The B record will plot a horizontal color bar, psscale-style in the middle, starting at offset from the left edge, and of the given height. You may add any additional psscale options from the list: −A −B −E −I −L −M −N −S and −Z.

C textcolor

The C record specifies the color with which the remaining text is to be printed. textcolor can be in the form r/g/b, c/m/y/k, or a named color.

D offset pen

The D record results in a horizontal line across the legend. The line starts and stops offset units from the frame sides, and is drawn using the specified pen. (See SPECIFYING PENS below).

| G gap |  | The G record specifies a vertical gap of the given length. In addition to the standard units (i, c, p) you may use l for lines.

H fontsize font Header

The H record plots a centered text string using the specified font parameters.

I imagefile width justification

Place an EPS or Sun raster image in the legend justified relative to the current point. The image width determines the size of the image on the page.

L fontsize font justification Label

The L record plots a (L)eft, (C)entered, or (R)ight-justified text string using the specified font parameters.

M slon|- slat length f|p [ −R w/e/s/n −J param ]

Place a map scale in the legend. Specify slon slat, the point on the map where the scale applies (slon is only meaningful for certain oblique projections. If not needed, you must specify - instead), length, the length of the scale in km (append m or n for miles or nautical miles), and f|p for fancy or plain scale. If the −R −J supplied to pslegend is different than the projection needed for the scale, supply the optional −R −J settings as well. Note that length can have :label:just appended, where label replaces the default label (unless - is given) and just (l|r|t|b) dictates where the label is placed [Default is t]. Use u to treat the label as distance units appended to each annotation.

N ncolums

Change the number of columns in the legend [1].

S dx1 symbol size fill pen dx2 text

Plots the selected symbol with specified size, fill, and outline. The symbol is centered at dx1 from the left margin of the column, with the explanatory text starting dx2 from the margin. Use - if no fill is required. Two psxy symbols front (f) and vector (v) require special attention. You must prepend the length of the desired item to the rest of the symbol argument; this will be used internally to set the correct fault or vector length and will be stripped before passing the arguments to psxy.

> <paragraph mode header for pstext>

Start a new text paragraph by specifying all the parameters needed (see pstext −M description). Note that pslegend knows what all those values should be, so normally you can leave the entire record (after >) blank. If you need to set at least one of the parameters directly, you must specify all and set the ones you want to leave at their default value to -.

T paragraph-text

One or more of these T records with text must follow after the > record.

V offset pen

The V record draws a vertical line between columns (if more than one) using the selected pen (See SPECIFYING PENS below). offset is analogous to the offset for the D records but in the vertical direction.

| −D |  | Positions the legend and specifies its size. The just is a 2-char justification string (see pstext) that relates the given position to a point on the rectangular legend box. If you want to specify the position in projected units (i.e., inches or cm), use −Dx.

−J

Selects the map projection. Scale is UNIT/degree, 1:xxxxx, or width in UNIT (upper case modifier). UNIT is cm, inch, or m, depending on the MEASURE_UNIT setting in .gmtdefaults4, but this can be overridden on the command line by appending c, i, or m to the scale/width value. When central meridian is optional, default is center of longitude range on −R option. Default standard parallel is the equator. For map height, max dimension, or min dimension, append h, +, or - to the width, respectively.

More details can be found in the psbasemap man pages.

CYLINDRICAL PROJECTIONS:

−Jc lon0/lat0/scale (Cassini)
−Jcyl_stere/[lon0/[lat0/]]scale (Cylindrical Stereographic)
−Jj[lon0/]scale (Miller)
−Jm[lon0/[lat0/]]scale (Mercator)
−Jm lon0/lat0/scale (Mercator - Give meridian and standard parallel)
−Jo[a]lon0/lat0/azimuth/scale (Oblique Mercator - point and azimuth)
−Jo[b]lon0/lat0/lon1/lat1/scale (Oblique Mercator - two points)
−Joc lon0/lat0/lonp/latp/scale (Oblique Mercator - point and pole)
−Jq[lon0/[lat0/]]scale (Cylindrical Equidistant)
−Jt lon0/[lat0/]scale (TM - Transverse Mercator)
−Ju zone/scale (UTM - Universal Transverse Mercator)
−Jy[lon0/[lat0/]]scale (Cylindrical Equal-Area)

CONIC PROJECTIONS:

−Jb lon0/lat0/lat1/lat2/scale (Albers)
−Jd lon0/lat0/lat1/lat2/scale (Conic Equidistant)
−Jl lon0/lat0/lat1/lat2/scale (Lambert Conic Conformal)

AZIMUTHAL PROJECTIONS:

−Ja lon0/lat0[/horizon]/scale (Lambert Azimuthal Equal-Area)
−Je lon0/lat0[/horizon]/scale (Azimuthal Equidistant)
−Jf lon0/lat0[/horizon]/scale (Gnomonic)
−Jg lon0/lat0[/horizon]/scale (Orthographic)
−Jg lon0/lat0/altitude/azimuth/tilt/twist/Width/Height/scale (General Perspective).
−Js lon0/lat0[/horizon][/slat]/scale (General Stereographic)

MISCELLANEOUS PROJECTIONS:

−Jh[lon0/]scale (Hammer)
−Ji[lon0/]scale (Sinusoidal)
−Jkf[lon0/]scale (Eckert IV)
−Jk[s][lon0/]scale (Eckert IV)
−Jn[lon0/]scale (Robinson)
−Jr[lon0/]scale (Winkel Tripel)
−Jv[lon0/]scale (Van der Grinten)
−Jw[lon0/]scale (Mollweide)

NON-GEOGRAPHICAL PROJECTIONS:

−Jp[a]scale[/origin][r|z] (Polar coordinates (theta,r))
−Jx x-scale[d|l|p pow|t|T][/y-scale[d|l|p pow|t|T]] (Linear, log, and power scaling)

−R

xmin, xmax, ymin, and ymax specify the Region of interest. For geographic regions, these limits correspond to west, east, south, and north and you may specify them in decimal degrees or in [+-]dd:mm[:ss.xxx][W|E|S|N] format. Append r if lower left and upper right map coordinates are given instead of w/e/s/n. The two shorthands −Rg and −Rd stand for global domain (0/360 and -180/+180 in longitude respectively, with -90/+90 in latitude). For calendar time coordinates you may either give (a) relative time (relative to the selected TIME_EPOCH and in the selected TIME_UNIT; append t to −JX|x), or (b) absolute time of the form [date]T[clock] (append T to −JX|x). At least one of date and clock must be present; the T is always required. The date string must be of the form [-]yyyy[-mm[-dd]] (Gregorian calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock string must be of the form hh:mm:ss[.xxx]. The use of delimiters and their type and positions must be exactly as indicated (however, input, output and plot formats are customizable; see gmtdefaults).

## OPTIONS

No space between the option flag and the associated arguments.

| −C |  | Sets the clearance between the legend frame and the internal items [0.15c/0.15c (or 0.05i/0.05i)].
| −F |  | Draws a border around the legend using FRAME_PEN.
| −G |  | Select fill shade, color or pattern of the legend box [Default is no fill]. (See SPECIFYING FILL below).
| −K |  | More PostScript code will be appended later [Default terminates the plot system].
| −L |  | Sets the linespacing factor in units of the current annotation font size [1.1].
| −O |  | Selects Overlay plot mode [Default initializes a new plot system].
| −P |  | Selects Portrait plotting mode [Default is Landscape, see gmtdefaults to change this].
| −S |  | Instead of writing the PostScript plot [Default], output the GMT script used to make the legend to standard output, or optionally to the file script.

−U

Draw Unix System time stamp on plot. By adding just/dx/dy/, the user may specify the justification of the stamp and where the stamp should fall on the page relative to lower left corner of the plot. For example, BL/0/0 will align the lower left corner of the time stamp with the lower left corner of the plot. Optionally, append a label, or c (which will plot the command string.). The GMT parameters UNIX_TIME, UNIX_TIME_POS, and UNIX_TIME_FORMAT can affect the appearance; see the gmtdefaults man page for details. The time string will be in the locale set by the environment variable TZ (generally local time).

| −V |  | Selects verbose mode, which will send progress reports to stderr [Default runs "silently"].

−X −Y

Shift plot origin relative to the current origin by (x-shift,y-shift) and optionally append the length unit (c, i, m, p). You can prepend a to shift the origin back to the original position after plotting, or prepend r [Default] to reset the current origin to the new location. If −O is used then the default (x-shift,y-shift) is (0,0), otherwise it is (r1i, r1i) or (r2.5c, r2.5c). Alternatively, give c to align the center coordinate (x or y) of the plot with the center of the page based on current page size.

| −c |  | Specifies the number of plot copies. [Default is 1].

SPECIFYING PENS

pen

The attributes of lines and symbol outlines as defined by pen is a comma delimetered list of width, color and texture, each of which is optional. width can be indicated as a measure (points, centimeters, inches) or as faint, thin[ner|nest], thick[er|est], fat[ter|test], or obese. color specifies a grey shade or color (see SPECIFYING COLOR below). texture is a combination of dashes ‘-’ and dots ‘.’.

SPECIFYING FILL

fill

The attribute fill specifies the solid shade or solid color (see SPECIFYING COLOR below) or the pattern used for filling polygons. Patterns are specified as p dpi/pattern, where pattern gives the number of the built-in pattern (1-90) or the name of a Sun 1-, 8-, or 24-bit raster file. The dpi sets the resolution of the image. For 1-bit rasters: use P dpi/pattern for inverse video, or append :F color[B[color]] to specify fore- and background colors (use color = - for transparency). See GMT Cookbook & Technical Reference Appendix E for information on individual patterns.

SPECIFYING COLOR

| color |  | The color of lines, areas and patterns can be specified by a valid color name; by a grey shade (in the range 0−255); by a decimal color code (r/g/b, each in range 0−255; h-s-v, ranges 0−360, 0−1, 0−1; or c/m/y/k, each in range 0−1); or by a hexadecimal color code (#rrggbb, as used in HTML). See the gmtcolors manpage for more information and a full list of color names.

## EXAMPLES

To add an example of a legend to a Mercator plot (map.ps) with the given specifications, use

pslegend −R-10/10/-10/10 −JM4i −G255 −D0/0/4i/3i/BL << EOF >> map.ps
G -0.15i
H 24 Times-Roman My Map Legend
G 0.05i
D 0.2i 1p
N 2
V 0 1p
S 0.1i c 0.15i p300/12 0.25p 0.3i This circle is hachured
S 0.1i t 0.15i yellow 0.25p 0.3i This triangle is yellow
S 0.1i h 0.15i green 0.25p 0.3i This hexagon is green
S 0.1i d 0.15i blue 0.25p 0.3i This diamond is blue
S 0.1i - 0.15i - 0.25tap 0.3i A contour
V 0 1p
D 0.2i 1p
N 1
I SOEST_logo.ras 3 CT
L 9 4 R Smith et al., @%5%J. Geophys. Res., 99@%%, 2000
G 0.5i
>
T Let us just try some simple text that can go on a few lines.
T There is no easy way to predetermine how many lines will be required,
T so we may need to adjust the box height to get the right size.
G -0.3i
M 5 5 1000:km:l f
EOF

SPECIFYING FILL

fill

The attribute fill specifies the solid shade or solid color (see SPECIFYING COLOR below) or the pattern used for filling polygons. Patterns are specified as p dpi/pattern, where pattern gives the number of the built-in pattern (1-90) or the name of a Sun 1-, 8-, or 24-bit raster file. The dpi sets the resolution of the image. For 1-bit rasters: use P dpi/pattern for inverse video, or append :F color[B[color]] to specify fore- and background colors (use color = - for transparency). See GMT Cookbook & Technical Reference Appendix E for information on individual patterns.

SPECIFYING COLOR

| color |  | The color of lines, areas and patterns can be specified by a valid color name; by a grey shade (in the range 0−255); by a decimal color code (r/g/b, each in range 0−255; h-s-v, ranges 0−360, 0−1, 0−1; or c/m/y/k, each in range 0−1); or by a hexadecimal color code (#rrggbb, as used in HTML). See the gmtcolors manpage for more information and a full list of color names.

## WINDOWS REMARKS

Note that under Windows, the percent sign (%) is a variable indicator (like $ under Unix). To indicate a plain percentage sign in a batch script you need to repeat it (%%); hence the font switching mechanism (@%font% and @%%) may require twice the number of percent signs. This only applies to text inside a script or that otherwise is processed by DOS. Data files that are opened and read by pslegend do not need such duplication.

## SEE ALSO

GMT(1), psbasemap(1), pstext(1), psxy(1)