polygon_coords: Makes coordinates for a regualr polygon

Description Usage Arguments Details Examples

View source: R/heat_tree--shape_generators.R

Description

Generates an n x 2 matrix containing x and y coordinates between 1 and 0 for the points of a regular polygon.

Usage

1
polygon_coords(n = 5, x = 0, y = 0, radius = 1, angle = 0)

Arguments

n

(numeric of length 1) The number of nodes in the polygon.

x

(numeric of length 1) x coordinate of center

y

(numeric of length 1) y coordinate of center

radius

(numeric of length 1) The diameter of the circle.

angle

(numeric of length 1) Angle to rotate points around the center of the circle.

Details

Inspired by (i.e. stolen from) https://gist.github.com/baptiste/2224724, which was itself inspired from a post by William Dunlap on r-help (10/09/09)

Examples

1
2
3
4
5
6
7
## Not run: 
library(ggplot2)
ggplot(data = polygon_coords(n = 4:13, x = rnorm(10), y = rnorm(10), radius = .5)) + 
  geom_polygon(aes(x = x, y = y, fill = group))

## End(Not run)
  

metacoder documentation built on May 23, 2017, 9:10 a.m.

Search within the metacoder package
Search all R packages, documentation and source code