.BG
.FN legend
.TL
Put a Legend on a Plot
.CS
legend(x, y, legend, angle, density, fill,
       col, lty, marks, pch, ncol=1, background=0)
.AG x,y
location of the rectangle in which to put the legend.
If `x' and `y' are length 1, they determine the top left
corner of the rectangle; 
if they are length 2, they give opposite corners of the rectangular
area.
A list containing x and y values may be supplied.
.AG legend
vector of text strings to be associated with shading patterns, line types,
plotting characters or marks.
.AG angle
optional vector giving the angle (degrees, counter-clockwise
from horizontal) for shading each bar division.
Defaults to 45 if `density' is supplied.
.AG density
optional vector for bar shading, giving the number of lines
per inch for shading each bar division.
Defaults to 5 if `angle' is supplied.
.AG fill
optional vector of colors for filled boxes.
.AG col
optional vector giving the colors in which the
points and lines should be drawn.
.AG lty
optional vector of line types.
.AG marks
optional vector of plotting symbol numbers
(see documentation for function `lines').
.AG pch
optional character string of plotting characters.
Single characters from `pch' will be used (see the example).
.AG ncol
number of columns.
.AG background
color for background of legend.
.GR
.PP
`legend' draws a box at specified coordinates and puts
inside examples of lines, points, marks, and/or shading,
each identified with a user-specified text string.
.SA
documentation for `barplot' contains a sample legend.
.EX
# use locator to point at upper-left corner
# of area to contain the legend -- draw colored boxes
legend(locator(1),legend=c("IBM","AT&T","GM"),fill=2:4)

# draw legend with different line styles and plotting chars
legend(0,10,names,lty=1:5,pch="O+*")
.KW aplot
.WR
