Add Hexagonal Cells to Plot of "hexbin" Object

DESCRIPTION:

Plots hexagonal cells defined by an object of class hexbin. This function is primarily support for the function plot.hexbin.

USAGE:

hexagons(bin, style="grayscale", cuts=16, col.regions= 
     trellis.par.get("regions")$col, at, mincount=1, 
     rmaxcount=max(bin$count), minarea=0.04, maxarea=0.8, 
     density=-1, border=F) 

REQUIRED ARGUMENTS:

bin
an object of class "hexbin".

OPTIONAL ARGUMENTS:

style
One of the strings "grayscale","lattice","centroids","nested.lattice", or "nested.centroids" representing the style of plot desired. See the DETAILS section for the description of each option. Partial string matching is allowed.
cuts
gives the number of levels to divide up the range of the number of counts for each bin. This is used for generating the at vector. How many different colors are used will depend, to an extent, on this parameter. Default is 16.
col.regions
numeric vector integers. These correspond to the colors in the graphics device colormap that are to be used to color the hexagons. Different color devices have more or less adequate colormaps. Using a device defined with a call to trellis.device will ensure that a colormap close to adequate is used. See the DETAILS section for ways to select other colormaps.
at
numeric vector giving the breaks at which to divide the range of cell counts. This allows more flexibility in the coloring by allowing non-equally spaced color intervals. If at is omitted, it is computed as seq(min(bin$count),max(bin$count),length=cuts).
mincount
cells with counts smaller that mincount are not shown.
maxcount
cells with counts larger that maxcount are not shown.
minarea
minimum symbol area as a fraction of the binning cell. The fraction of cell area for the lowest count. If small hexagons are hard to see, increase minarea.
maxarea
maximum symbol area as a fraction of the binning cell. The fraction of the cell area for the largest count.
density
density of shading lines in lines per inch. If density is zero, no shading will occur. If density is negative, the polygon will be filled solidly using the device-dependent polygon filling algorithm. This is the same as the density argument to the S-PLUS function polygon.
border
logical flag: should the border of the hexagons be drawn?

SIDE EFFECTS:

Adds hexagons to the plot.

DETAILS:

The five plotting styles are:

style="grayscale" A smoothly varying color mapping of the counts is determined from the values in cuts, at, and col.regions. The best use of this option requires that the plotting device is activated through a call to the S-PLUS function trellis.device. This ensures that an adequate color map is the default although other devices as well as customized colormaps can be provided by the user.

style="lattice" or "centroids" Plots the hexagons in sizes proportional to cell counts. The "lattice" option places the hexagons at the lattice centers. In some cases, the regularity of this structure may be visually overwhelming. In those cases, the user should use the "centroids" option which places the hexagons at their centers of mass. This results in the breaking of the regularity of the lattice structure thereby placing the focus on other properties of the data. In all cases the hexagons will not plot outside the cell unless maxarea > 1.

style="nested.lattice" and "nested.centroids" Two overlaying hexagons are plotted: a background hexagon with area covering the full hexagon's and color proportional to the cell count in powers of 10 and a foreground hexagon with area proportional to log10(count)-floor(log10(count)). When style="nested.centroids" counts <10 are plotted and the centers of the plotted hexagons are placed at their centers of mass. The outside color encodes hexagon size within color contours representing powers of 10. Different color schemes give different effects including 3-D illusions

The hexagon sizes are scaled proportionally to cell counts by scaling the counts between mincount and maxcount and then mapping to areas between minarea and maxarea.

PERCEPTUAL CONSIDERATIONS:

Plotting the symbols near the center of mass is not only more accurate, it helps reduce the visual dominance of the lattice structure. Of course higher resolution binning reduces the possible distance between the center of mass for a bin and the bin center. When symbols nearly fill their bin, the plot appears to vibrate. This can be partially controlled by reducing maxarea or by reducing contrast.

The local background influences color interpretation. Having defined color breaks to focus attention on specific contours can help. See nested options.

REFERENCES:

Carr, D. B. (1991). Looking at large data sets using binned data plots. In Computing and Graphics in Statistics. A. Buja and P. Tukey, eds. Springer-Verlag, New York. pp. 7-39.

SEE ALSO:

, , , , , .

EXAMPLES:

x <- quakes.bay[,"longitude"]; y <- quakes.bay[,"latitude"]
bin <- hexbin(x, y) 
plot(range(bin$x), range(bin$y), type='n') 
hexagons(bin)