plotAddLegend {MorphoTools2}R Documentation

Add Legend to a Plot

Description

This function can be used to add legend to plot.

Usage

plotAddLegend(result, x = "topright", y = NULL, pch = 16, col = "black",
    pt.bg = "white", pt.cex = cex, pt.lwd = 1, x.intersp = 1,
    y.intersp = 1, box.type = "o", box.lty = "solid", box.lwd = 1,
    box.col = "black", box.bg = "white", cex = 1, ncol = 1, horiz = FALSE, ...)

Arguments

result

result of pca.calc, pcoa.calc, nmds.calc, or cda.calc, has to by plotted at first.

x, y

the x and y coordinates or a single keyword from the list "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right", and "center", to be used to position the legend.

pch

the plotting symbols of points appearing in the legend.

col

the colours of points appearing in the legend.

pt.bg

the background colour for the points, corresponding to its argument bg.

pt.cex

character expansion factor for the points.

pt.lwd

the line width for the points.

x.intersp, y.intersp

character interspacing factor for horizontal (x) and vertical (y) line distances.

box.type

the type of box to be drawn around the legend. The applicable values are "o" (the default) and "n".

box.lty, box.lwd, box.col, box.bg

the line type, width colour and background colour for the legend box (if box.type = "o").

cex

character expansion factor for text.

ncol

the number of columns in which to set the legend item.

horiz

logical; if TRUE, set the legend horizontally rather than vertically (specifying horiz overrides the ncol specification).

...

further arguments to be passed to legend or other graphical parameters in par.

Value

None. Used for its side effect of adding elements to a plot.

Examples

data(centaurea)
centaurea = naMeanSubst(centaurea)
centaurea = removePopulation(centaurea, populationName = c("LIP", "PREL"))

pcaRes = pca.calc(centaurea)

plotPoints(pcaRes, col = c("red", "green", "blue", "red"),
            pch = c(20, 17, 8, 21), pt.bg = "orange", legend = FALSE)

plotAddLegend(pcaRes, x = "bottomright", col = c("red", "green", "blue", "red"),
               pch = c(20, 17, 8, 21), pt.bg = "orange", ncol = 2)

[Package MorphoTools2 version 1.0.1.1 Index]