grid_hex {ggvfields} | R Documentation |
Generate a Hexagonal Lattice
Description
This function generates a hexagonal lattice of points within the given x and y limits, using a specified hexagon diameter. The diameter is 2 times the distance between adjacent x (and y) values, see examples.
Usage
grid_hex(xlim, ylim, d)
Arguments
xlim |
A numeric vector of length 2 specifying the x-axis limits. |
ylim |
A numeric vector of length 2 specifying the y-axis limits. |
d |
A numeric value specifying the hexagon diameter. |
Value
A data frame with two columns, x
and y
, containing the
coordinates of the hexagonal grid points.
Examples
xlim <- c(-1, 1)
ylim <- c(-1, 0)
grid <- grid_hex(xlim, ylim, .25)
head( grid )
str( grid )
plot( grid, asp = 1 )
diff(sort(unique(grid$x)))
[Package ggvfields version 1.0.0 Index]