Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

hexViewport

Compute a Grid Viewport for Hexagon / Hexbin Graphics


Description

Builds a grid viewport for hexagon or hexbin graphics. This builds on the concepts of the grid package, see viewport.

Usage

hexViewport(x, offset = unit(0,"inches"), mar = NULL,
	    xbnds = NULL, ybnds = NULL, newpage = FALSE,
            clip = "off", vp.name = NULL)

Arguments

x

a hexbin object.

offset

a unit object.

mar

margins as units, of length 4 or 1.

xbnds, ybnds

bounds for x- and y- plotting range; these default to the corresponding slots of x.

newpage

logical indicating if a new graphics page should be openend, i.e., grid.newpage().

clip

simply passed to viewport().

vp.name

name of viewport; defaults to random name.

Value

an S4 object of class "hexVP", see hexVP-class for more, with its main slot hexVp a viewport for grid graphics.

See Also

viewport and the main “handlers” pushHexport and popViewport; further gplot.hexbin and hboxplot which build on hexViewport.

Examples

set.seed(131)
x <- rnorm(7777)
y <- rt   (7777, df=3)

## lower resolution binning and overplotting with counts
bin <- hexbin(x,y,xbins=25)
P <- plot(bin)
xy <- hcell2xy(bin)
pushHexport(P$plot.vp)
i <- bin@count <= 3
library("grid")
grid.text(as.character(bin@count[i]), xy$x[i], xy$y[i],
          default.units = "native")
grid.points(x[1:20],y[1:20]) # to show some points rather than counts
popViewport()

hexbin

Hexagonal Binning Routines

v1.28.2
GPL-2
Authors
Dan Carr <dcarr@voxel.galaxy.gmu.edu>, ported by Nicholas Lewin-Koh and Martin Maechler <maechler@stat.math.ethz.ch>, contains copies of lattice functions written by Deepayan Sarkar <deepayan.sarkar@r-project.org>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.