plot.hexbin(bin, style="grayscale", minarea=0.04, maxarea=0.8,
mincount=1, maxcount=max(bin$count), cuts=min(16, maxcount),
col.regions=trellis.par.get("regions")$col,
at=pretty(bin$count, cuts), border=F, density=-1, legend=T,
legend.width=1, legend.lab="Counts", legend.cex=1, xlab="",
ylab="", ...)
Graphical parameters may also be supplied as arguments to this function (see par).
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 equal to 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.
A way to try different colormaps is by using the Options pull down menu in your graphics device driver and typing in your own color map in the Polygons widget. For smoothly varying colormaps, you may want to copy the Image colors into the Polygons slot.
Plotting the symbols near the center of mass is not only more accurate, but 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.
# Simple binning x <- rnorm(10000) y <- rnorm(10000)mybin <- hexbin(x,y)
# Basic plot plot(mybin,style="nested.lat")
# Lower resolution binning and overplotting with counts mybin2 <- hexbin(x, y, xbins=20) screenpar <- plot(mybin2, style="lat", minarea=1, maxarea=1, density=0,border=T) oldpar <- par(screenpar) # reset graphic parameters according # to the plot on the screen. xy <- cell2xy(mybin2) text(xy$x, xy$y, format(bin$count), adj=.5, cex=.3)
par(oldpar) # reset graphic parameters back for # subsequent plotting.
# Histogram equalization to determine amount of color # Use quantile function to break up the number of counts into # more or less equal size groups at.q <- quantile(mybin$count,probs=seq(10,100,10)/100) plot(mybin,at=at.q)
# More detail for low counts, use a log transform to determine # the breaks at.l <- range(log(mybin$count)) plot(mybin,at=exp(seq(at.l[1],at.l[2],length=10)))