polygon2 | R Documentation |
Draw regular polygon
s as plotting characters. This
function calculates the {x,y}
coordinates for given centroids and
radii and passes each pair of vectors to polygon
to draw.
Note that all arguments except x
, y
, radius
,
sides
, and srt
are passed directly to polygon
,
so see ?polygon
for additional details.
polygon2(
x,
y = NULL,
radius,
sides = 6,
srt = 0,
density = NULL,
angle = 45,
border = NULL,
col = NA,
lty = par("lty"),
fillOddEven = FALSE,
...
)
x, y |
x- and y-coordinate vectors of polygon centroids |
radius |
distance from centroid to each vertex |
sides |
number of sides for polygons; since only regular polygons may
be plotted, possible values are |
srt |
rotation in degrees for polygon |
density |
density of shading lines in lines per inch |
angle |
slope of shading lines, given as an angle in degrees (counter- clockwise) |
border |
polygon border color |
col |
polygon fill color |
lty |
line type to be used for border and/or shading lines |
fillOddEven |
logical controlling polygon shading mode |
... |
additional graphical parameters such as |
## sides can be any of
(sides <- (1:360)[360L %% 1:360 == 0L])
plot.new()
for (ii in sides)
polygon2(0.5, 0.5, sides = ii) ## okay
# polygon2(0.5, 0.5, sides = 7) ## error
x <- mtcars$mpg
y <- mtcars$wt
plot(x, y, type = 'n', asp = 1)
polygon2(x, y, density = 30, angle = 90, col = mtcars$gear)
polygon2(x, y + 1, srt = 30, lty = 'dotted', col = 'transparent')
polygon2(x, y + -2, radius = .5, sides = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.