[ top | up ]

Add Legends to Plots

Syntax

legend(x, y, legend, fill=, col="black",
        lty=, pch=, bty="o", bg=par("bg"),
        xjust=0, yjust=1)

Arguments

x the x location of the legend.
y the y location of the legend.
legend a vector of text values to appear in the legend.
fill if specied, this argument will cause boxes filled with the specified colors to appear beside the legend text.
col the color of points or lines appearing in the legend.
lty the line types for lines appearing in the legend.
pch the plotting symbols appearing in the legend.
bty the type of box to be drawn around the legend.
bg the background color for the legend box.
xjust how the legend is to be justified relative to the legend x location. A value of 0 means left justified, 0.5 means centered and 1 means right justified.
yjust how the legend is to be justified relative to the legend y location. A value of 0 means top justified, 0.5 means centered and 1 means bottom justified.

Description

This function can be used to add legends to plots. Note that a call to the function locator can be used in place of the x and y arguments.

See Also

plot, barplot.

Examples

# There are no examples yet.