Add a Legend Hexagonal Lattice Plot

DESCRIPTION:
Adds a legend to the plot of an object of class "hexbin". To be called by the corresponding plot method. The legend represents the lattice counts. This function is support for plot.hexbin, it is not meant to be called directly by the user.

USAGE:
hex.legend(col, at, labels=format(round(at)), legend.lab="Counts",
    height=3, lcex=1, width=1, inner, style="grayscale", minarea=0.04,
    maxarea=0.8, maxcount, density=-1)

REQUIRED ARGUMENTS:
col:
numeric vector of color numbers used to color the different levels in the color legend.
at:
numeric vector specifying the values at which the colors change.

OPTIONAL ARGUMENTS:
labels:
a character vector of tick labels marking the value of at.
legend.lab:
a character string denoting a title for the legend itself. The default is "Counts".
height:
total height of the legend in inches. The default is 3 inches.
lcex:
numeric constant. Character expansion for the legend text. Default is 1.
width:
numeric constant giving the desired width of the legend. Default is 1.
inner:
numeric constant needed to determine the size of the hexagons. Default is computed as a function of width. (Inner diameter in inches.)
style:
character string. One of 5 possible styles for plotting the hexagons. This must be one of "grayscale","lattice","centroids","nested.lattice", or "nested.centroids".
minarea:
fraction of cell area for the lowest count. Default is 0.04 or 4%.
maxarea:
fraction of the cell area for the largest count. Default is 80%.
maxcount:
cells with more counts than maxcount are ignored.
density:
same as the corresponding argument in the function polygon. If density is zero, no shading will occur. If density is negative, the hexagons will be filled solidly.

SIDE EFFECTS:
A legend is added to the current plot.

DETAILS:
This function must not be used as a standalone function. It is meant to be called from plot.hexbin.

SEE ALSO:
plot.hexbin , hexagons