Learn R Programming

LSC (version 0.1.5)

make_legend: Add a color-scale legend to a plot

Description

This function adds a nicely formatted color-scale legend to a plot. NOTE: This function will be made available in the LICORS package in the next release. It will then be removed from the NAMESPACE of the LSC package.

Usage

make_legend(data = NULL, col = NULL, side = 1, zlim = NULL, col.ticks = NULL, 
    cex.axis = 2, max.height = 1, col.label = "")

Arguments

data
data for which the legend should be plotted
side
on which side of the plot (1=bottom, 2=left, 3=top, 4=right)
col.ticks
color tick marks
max.height
height of the density plot (typically not modified by user)
cex.axis
The magnification to be used for axis annotation relative to the current setting of cex.
col
colors: either a string decribing a pallette from the RColorBrewer package (see also http://colorbrewer2.org/), or a list of colors (see image for suggestions).
zlim
minimum and maximum z values for which colors should be plotted, defaulting to the range of the finite values of data.
col.label
same as zlim.label

Examples

Run this code
xx <- rnorm(100)
make_legend(xx, col = "RdBu")
make_legend(xx, col = "RdYlGn", side = 4)

Run the code above in your browser using DataLab