Description Usage Arguments Value Examples
View source: R/visualizations.R
Draw different types of convex hulls around a set of points
1 2 |
x,y |
The x and y coordinates of a set of points. Alternatively, a single argument x can be provided. |
alpha |
Proportion of points most distant from centroid to be removed before creating the (peeled) convex hull. |
peel |
Remove hull points? (useful to remove outliers,
default |
smooth |
Integer (1 to 3) indicating the method for creating splines around the hull. |
shape |
Shape parameter used for |
draw |
Draw the hull polygon (default |
... |
additional parameters passed to |
A list as given by xy.coords
containing the
hull points is returned invisibly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | set.seed(2)
x <- rnorm(100)
y <- rnorm(100)
op <- par(mfrow=c(2,3), mar=c(3,2,3,1))
plot(x,y, main="convex hull")
convex_hull(x,y)
plot(x,y, main="colored hull")
convex_hull(x,y, col="#FF000050", density=10, angle=45, border="red")
plot(x,y, main="20% of most distant\npoints removed")
convex_hull(x,y, alpha=.2, col="#FF000050", density=10, angle=45, border="red")
plot(x,y, main="initial hull points\nremoved (peeled off)")
convex_hull(x,y, peel=T, col="#00FF0050", border="red")
plot(x,y, main="smoothed hull\n(spline interpolated)")
convex_hull(x,y, smooth=2, col="#FF000050", border="red")
plot(x,y, main="another smooting\nmethod")
convex_hull(x,y, peel=T, smooth=1, shape=1, col="#00FF0050", border="red")
par(op)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.