Learn R Programming

gplots (version 2.3.0)

smartlegend: Place a legend in a specified logical ("top","bottom", "left", "right", etc) location on a plot.

Description

This function places a legend in a specified logical ("top","bottom", "left", "right", etc) location on a plot.

Usage

smartlegend(x = c("left", "center", "right"),
            y = c("top", "center", "bottom"),
            ..., inset = 0.05)

Arguments

x
horizontal location on the plot. One of "left", "center" or "right".
y
vertical location on the plot. One of "top", "center", or "bottom".
...
arguments for legend
inset
inset distance from the margin as a fraction of the plot region.

Value

  • Same as legend

See Also

legend

Examples

Run this code
x <- rnorm(100)
y <- rnorm(100, x^2 )
plot(x,y)
abline( lm(y~x), col="red", lty=1, type="b") # regression fit
lines( lowess(y~x), col="blue", lty=2, type="b") # lowess fit

smartlegend(x="center", y="top",
            c("Regression","Locally Linear Smooth"),
            col=c("red","blue"), lty=1:2)

Run the code above in your browser using DataLab