ngon: Draw a regular n-gon

View source: R/ngon.R

ngonR Documentation

Draw a regular n-gon

Description

Draws a regular polygon with n sides, such as a triangle (n=3) or hexagon (n=6).

Usage

ngon(x = 0, y = 0, s = 1, n = 6, angle = 0, fix.aspect = TRUE, ...)

Arguments

x

vector of x-coordinates specifying the centres of the n-gons.

y

vector of y-coordinates specifying the centres of the n-gons.

s

side lengths; either a single number or a vector of the same length as x and y. In log-log plots, the value of s is in units of dex.

n

number of sides of the regular n-gons; either a single number or a vector of the same length as x and y.

angle

rotation angle in radians; either a single number or a vector of the same length as x and y.

fix.aspect

logical flag. If TRUE (default), the aspect ratio of the n-gon on the screen is forced to be unity, even if the this makes it irregular in the coordinates of the plot. If FALSE, the n-gon is regular in plot coordinates, which makes it distorted in screen coordinates if the aspect ratio is not one and/or if logarithmic coordinates are used.

...

additional arguments used by polygon.

Value

None.

Author(s)

Danail Obreschkow

Examples


## Plot random points on the unit sphere in Mollweide projection
# hexagon at the center of a plot
nplot(bty='o', asp=0.5)
ngon(x=0.5, y=0.5, s=0.1, n=6, fix.aspect=FALSE)

ngon(x=0.5, y=0.5, s=0.1, n=6, border='red')

plot(NA,xlim=c(1,1e3),ylim=c(1,1e5),log='xy')
ngon(x=10^runif(10,0,3), y=10^runif(10,0,5), s=1, n=6,  border='red',lwd=3)


obreschkow/cooltools documentation built on Nov. 16, 2024, 2:46 a.m.