| stat_voronoi | R Documentation |
See geom_voronoi for general use.
Use geom="polygon" for choropleth heatmap or geom="path" for region borders.
stat_voronoi(mapping = NULL, data = NULL, geom = "polygon", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, outline = NULL, ...)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use display the data |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
outline |
|
... |
Other arguments passed on to |
set.seed(45056)
x <- sample(1:200,100)
y <- sample(1:200,100)
points <- data.frame(x, y,
distance = sqrt((x-100)^2 + (y-100)^2))
circle <- data.frame(x = 100*(1+cos(seq(0, 2*pi, length.out = 2500))),
y = 100*(1+sin(seq(0, 2*pi, length.out = 2500))),
group = rep(1,2500))
ggplot(points) +
stat_voronoi(aes(x=x,y=y,fill=distance))
ggplot(points) +
stat_voronoi(aes(x=x,y=y),geom="path")
ggplot(points) +
stat_voronoi(aes(x=x,y=y,fill=distance),outline=circle)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.