Description Usage Arguments Value Examples
View source: R/polygon_operations.R
Scale polygons around their center
1 | scale_polygon(poly, scaling)
|
poly |
a data frame defining a polygon (x and y coordinates) |
scaling |
a numeric vector that defines the scaling factor |
data.frame defining a scaled polygon
1 2 3 4 5 6 7 8 9 10 | scale_polygon(data.frame(x = c(1, 2, 3), y = c(1, 2, 1)), 2)
poly <- data.frame(x = c(1, 1, 0, 0), y = c(1, 0, 0, 1))
library(ggplot2)
ggplot(data = NULL, aes(x = x, y = y)) +
geom_polygon(data = poly, fill = "black") +
geom_polygon(data = scale_polygon(poly, 0.5), fill = "gray") +
geom_polygon(data = scale_polygon(poly, 2), alpha = 0.2, fill = "red") +
geom_polygon(data = scale_polygon(poly, c(1, 3)), alpha = 0.2, fill = "green") +
geom_polygon(data = scale_polygon(poly, c(3, 1)), alpha = 0.2, fill = "blue")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.