hexagons.3d {hexbin}R Documentation

Add 3d Hexagon Facets to a Plot


Plots cells in an hexbin object using 3d hexagon facets. The function distinquishes among counts using 3 different styles.


hexagons.3d(dat, style = c("colorscale", "centroids", "lattice"),
            minarea = 0.05, maxarea = 0.8, mincnt = 1, maxcnt = max(dat$cnt),
            trans = NULL, colorcut, density = NULL,
            border.base = NULL, border.top = NULL, border.side = NULL,
            pen = NULL, lt.angle = 155, lt.azimuth = 45, rot = 0, inner = 0.5,
            colramp = function(n) { LinGray(n, beg = 90, end = 15) },
            verbose = getOption("verbose"))


dat an object of class hexbin, see hexbin.
style character specifying the type of plotting; must be one of ("grayscale", "lattice", "centroids").
minarea, maxarea fractions of the cell area for the lowest or largest count, respectively.
mincnt, maxcnt integer scalars: Cells with counts outside this range are not shown.
trans A transformation for the counts such as sqrt().
colorcut A vector of values covering [0, 1] which determine hexagon color classes boundaries or hexagon size boundaries.
density polygon() fill argument. 0 causes the polygon not to be filled.
border.base Polygon() border argument. Draw the basal border for each hexagon facet
border.top Polygon() border argument. Draw the basal border for each hexagon facet
border.side Polygon() border argument. Draw the basal border for each hexagon facet
pen Polygon() col argument. Determines the color with which the polygon will be filled
colramp function accepting n as its argument and returning n colors. n is determined
verbose logical indicating if some diagnostic output should happen.


The five plotting styles have the following effect:

style="lattice" or "centroids"
Plots the hexagons in different heights and center size based on counts. The "lattice" version centers the hexagons at the cell centers whereas "centroids" moves centers the hexagons close to the center of mass for the cells. The centroid version is experimental and not yet for human consumtion. In all cases the hexagons will not plot outside the cell. Counts are rescaled into the interval [0,1] and colorcuts determine the class boundaries for sizes and counts. The pen argument for this style should be a single color or a vector of colors of length(bin$cnt).
Counts are rescaled into the interval [0,1] and colorcuts determines the class boundaries for the color classes. For this style the function specified in coloramp is used to define the n colors for the n+1 color cuts. In for this style the pen argument is ignored.
Hexagon size encoding minarea and maxarea determine the area of the smallest and largest hexagons plotted. Both are expressed fractions of the bin cell size. Typical values might be .04 and 1. When both values are 1, all plotted hexagons are bin cell size, if maxarea is greater than 1 than hexagons will overlap. This is sometimes interesting with the lattice and centroid styles.

Count scaling

relcnt <- (trans(cnt)-trans(mincnt)) / (trans(maxcnt)-trans(mincnt))
area <- minarea + relcnt*maxarea

By default the transformation trans() is the identity function. The legend routine requires the transformation inverse for some options.

Count windowing mincnt and maxcnt Only routine only plots cells with cnts in [mincnts, maxcnts]



Adds hexagons to the plot.


Nicholas Lewin-Koh nikko@hailmail.net, inspired by Dan Carr dcarr@voxel.galaxy.gmu.edu


See Also

the simpler “flat” version of this, hexagons, and the auxiliary function hexagon3d.

Further, hexbin, smooth.hexbin, erode.hexbin, plot.hexbin


[Package hexbin version 1.0.10 Index]