This stat and geom allows you to display voronoi tesselation as polygons.
The computations are based on the deldir()
function.
geom_voronoi(mapping = NULL, data = NULL, stat = "voronoi", position = "identity", na.rm = FALSE, eps = 1e-09, normalize = FALSE, expand = 0, show.legend = NA, inherit.aes = TRUE, ...) StatVoronoi
mapping | Set of aesthetic mappings created by |
---|---|
data | The data to be displayed in this layer. There are three options: If A A |
stat | The statistical transformation to use on the data for this layer, as a string. |
position | Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm | If |
eps | A value of epsilon used in testing whether a quantity is zero, mainly in the context of whether points are collinear. If anomalous errors arise, it is possible that these may averted by adjusting the value of eps upward or downward. |
normalize | Should coordinates be normalized prior to calculations.
If |
expand | How much to expand the convex hull around the points. Default: 0.1; \(expand \times max(span(data$x), span(data$y))\) |
show.legend | logical. Should this layer be included in the legends?
|
inherit.aes | If |
... | Other arguments passed on to |
An object of class StatVoronoi
(inherits from Stat
, ggproto
, gg
) of length 3.
Understands the following aesthetics. Required aesthetics are in bold:
x
y
alpha
color
fill
linetype
size
library(ggplot2) ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_voronoi(aes(fill = Species)) + geom_point()#> Warning: Computation failed in `stat_voronoi()`: #> The packages sf and lwgeom are needed for the voronoi stat and geom.# Difference of normalize = TRUE ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_voronoi(aes(fill = Species), normalize = TRUE) + geom_point()#> Warning: Computation failed in `stat_voronoi()`: #> The packages sf and lwgeom are needed for the voronoi stat and geom.