Some notes about legends in #R
plots. There's a section on placing the legend in the plot margin.
A legend is a tool to help explain a graph. You are most commonly going to want to add one to a bar chart where you have several data series. You'll also want to add one to a line or scatter plot when you have more than one series. Essentially you use a legend to help make a complicated plot more understandable.
In R you can add a legend to any plot using the legend() command. You can also use the legend = TRUE parameter in the barplot() command. The barplot() command is the only general plot type that has a legend parameter (the others need a separate legend).
The legend() command has a host of parameters, which can be tweaked to produce the finished article. Generally the most difficult part is making room on the chart for the legend itself!