sidelegend: Put the legend on the side of a plot

View source: R/sidelegend.R

sidelegendR Documentation

Put the legend on the side of a plot

Description

sidemargin prepares the margin, sidelegend puts the legend in it.

Usage

sidelegend(...)

sidemargin()

Arguments

...

passed to legend.

Value

sidemargin returns the previous par settings, so that they can be reset for futher plots. sidelegend returns the same value as legend.

Examples

# Make a basic plot
attach(iris)
plot(Petal.Length, Petal.Width, col=Species, pch=19)
legend(1, 2, legend=levels(Species), col=1:nlevels(Species), pch=19)

# The same with the legend on the side
pars <- sidemargin()
plot(Petal.Length, Petal.Width, col=Species, pch=19)
sidelegend(legend=levels(Species), col=1:nlevels(Species), pch=19)
par(pars) # reset graphical parameters

jiho/chroma documentation built on Nov. 26, 2022, 2:39 a.m.