polygon(graphics)
polygon()所属R语言包:graphics
Polygon Drawing
多边形绘图
译者:生物统计家园网 机器人LoveR
描述----------Description----------
polygon draws the polygons whose vertices are given in x and y.
polygon绘制多边形的顶点x和y。
用法----------Usage----------
polygon(x, y = NULL, density = NULL, angle = 45,
border = NULL, col = NA, lty = par("lty"),
..., fillOddEven = FALSE)
参数----------Arguments----------
参数:x,y
vectors containing the coordinates of the vertices of the polygon.
多边形的顶点坐标的向量。
参数:density
the density of shading lines, in lines per inch. The default value of NULL means that no shading lines are drawn. A zero value of density means no shading nor filling whereas negative values and NA suppress shading (and so allow color filling).
阴影线的密度,以每英寸线。默认值NULL意味着没有阴影线绘制。一个零值density意味着没有阴影,也没有填写,而负值NA压制底纹(从而使颜色填充)。
参数:angle
the slope of shading lines, given as an angle in degrees (counter-clockwise).
遮光线的斜率,角度(逆时针)。
参数:col
the color for filling the polygon. The default, NA, is to leave polygons unfilled, unless density is specified. (For back-compatibility, NULL is equivalent to NA.) If density is specified with a positive value this gives the color of the shading lines.
填充多边形的颜色。默认情况下,NA,是离开多边形悬空,除非density指定。 (对于向后兼容性,NULL相当于NA。)如果density是一个积极的价值,这使阴影线的颜色与指定。
参数:border
the color to draw the border. The default, NULL, means to use par("fg"). Use border = NA to omit borders. For compatibility with S, border can also be logical, in which case FALSE is equivalent to NA (borders omitted) and TRUE is equivalent to NULL (use the foreground colour),
绘制边框的颜色。默认情况下,NULL,是指使用par("fg")。使用border = NA省略边框。与S的兼容性,border也可以是逻辑,在这种情况下,FALSE相当于NA(边框略)和TRUE是NULL(使用前景色),
参数:lty
the line type to be used, as in par.
要使用的线路类型,在par。
参数:...
graphical parameters such as xpd, lend, ljoin and lmitre can be given as arguments.
如xpd,lend,ljoin和lmitre图形参数可以作为参数。
参数:fillOddEven
logical controlling the polygon shading mode: see below for details. Default FALSE.
逻辑控制多边形的着色模式:详情见下文。默认FALSE。
Details
详情----------Details----------
The coordinates can be passed in a plotting structure (a list with x and y components), a two-column matrix, .... See xy.coords.
坐标可以通过在绘图结构(x和y组件的列表),一个两列的矩阵,...看到xy.coords。
It is assumed that the polygon is to be closed by joining the last point to the first point.
据推测,加入最后一点到第一点被封闭多边形。
The coordinates can contain missing values. The behaviour is similar to that of lines, except that instead of breaking a line into several lines, NA values break the polygon into several complete polygons (including closing the last point to the first point). See the examples below.
坐标可以包含缺失值。类似的行为是lines,除了分成几行线,而不是NA值分解成几个完整的多边形(包括关闭的最后一点到第一点)的多边形。见下面的例子。
When multiple polygons are produced, the values of density, angle, col, border, and lty are recycled in the usual manner.
当产生多个多边形,density值angle,col,border,lty在通常的方式回收。
Shading of polygons is only implemented for linear plots: if either axis is on log scale then shading is omitted, with a warning.
线性图仅实现多边形阴影:如果任一轴是对数刻度,那么阴影被忽略,一个警告。
错误----------Bugs----------
Self-intersecting polygons may be filled using either the “odd-even” or “non-zero” rule. These fill a region if the polygon border encircles it an odd or non-zero number of times, respectively. Shading lines are handled internally by R according to the fillOddEven argument, but device-based solid fills depend on the graphics device. The windows, pdf and postscript devices have their own fillOddEven argument to control this.
自相交的多边形可使用“单双号”或“非零”的规定填写。如果多边形的边界包围次奇数或非零数字,分别填补了区域。底纹线条处理内部的R根据到fillOddEven参数,但基于设备的固体填充取决于图形设备。 windows,pdf和postscript设备有自己的fillOddEven参数控制。
作者(S)----------Author(s)----------
The code implementing polygon shading was donated by
Kevin Buhr <a href="mailto:buhr@stat.wisc.edu">buhr@stat.wisc.edu</a>.
参考文献----------References----------
The New S Language. Wadsworth & Brooks/Cole.
参见----------See Also----------
segments for even more flexibility, lines, rect, box, abline.
segments更大的灵活性,lines,rect,box,abline。
par for how to specify colors.
par如何指定颜色。
举例----------Examples----------
x <- c(1:9,8:1)
y <- c(1,2*(5:3),2,-1,17,9,8,2:9)
op <- par(mfcol=c(3,1))
for(xpd in c(FALSE,TRUE,NA)) {
plot(1:10, main = paste("xpd =", xpd))
box("figure", col = "pink", lwd=3)
polygon(x,y, xpd=xpd, col="orange", lty=2, lwd=2, border="red")
}
par(op)
n <- 100
xx <- c(0:n, n:0)
yy <- c(c(0,cumsum(stats::rnorm(n))), rev(c(0,cumsum(stats::rnorm(n)))))
plot (xx, yy, type="n", xlab="Time", ylab="Distance")
polygon(xx, yy, col="gray", border = "red")
title("Distance Between Brownian Motions")
# Multiple polygons from NA values[从Na值的多个多边形]
# and recycling of col, border, and lty[山口,边界和回收,并LTY]
op <- par(mfrow=c(2,1))
plot(c(1,9), 1:2, type="n")
polygon(1:9, c(2,1,2,1,1,2,1,2,1),
col=c("red", "blue"),
border=c("green", "yellow"),
lwd=3, lty=c("dashed", "solid"))
plot(c(1,9), 1:2, type="n")
polygon(1:9, c(2,1,2,1,NA,2,1,2,1),
col=c("red", "blue"),
border=c("green", "yellow"),
lwd=3, lty=c("dashed", "solid"))
par(op)
# Line-shaded polygons[阴影线的多边形]
plot(c(1,9), 1:2, type="n")
polygon(1:9, c(2,1,2,1,NA,2,1,2,1),
density=c(10, 20), angle=c(-45, 45))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|