grid.path(grid)
grid.path()所属R语言包:grid
Draw a Path
绘制路径
译者:生物统计家园网 机器人LoveR
描述----------Description----------
These functions create and draw a path. The final point will automatically be connected to the initial point.
这些功能创建和绘制路径。最后一点,将自动连接到初始点。
用法----------Usage----------
pathGrob(x, y,
id=NULL, id.lengths=NULL,
rule="winding",
default.units="npc",
name=NULL, gp=gpar(), vp=NULL)
grid.path(...)
参数----------Arguments----------
参数:x
A numeric vector or unit object specifying x-locations.
一个数值向量或单位对象指定x的位置。
参数:y
A numeric vector or unit object specifying y-locations.
一个数值向量或单位对象指定的y位置。
参数:id
A numeric vector used to separate locations in x and y into sub-paths. All locations with the same id belong to the same sub-path.
一个数值向量用于x和y成子路径的不同地点。所有位置具有相同的id属于同一个子路径。
参数:id.lengths
A numeric vector used to separate locations in x and y into sub-paths. Specifies consecutive blocks of locations which make up separate sub-paths.
一个数值向量用于x和y成子路径的不同地点。指定的地点,使独立的子路径的连续块。
参数:rule
A character value specifying the fill rule: either "winding" or "evenodd".
指定一个字符值填充的规则:要么"winding"或"evenodd"。
参数:default.units
A string indicating the default units to use if x or y are only given as numeric vectors.
一个字符串,指示的默认单位使用,如果x或y只为数字向量。
参数:name
A character identifier.
字符识别。
参数:gp
An object of class gpar, typically the output from a call to the function gpar. This is basically a list of graphical parameter settings.
一个类的对象gpar,通常从调用输出函数gpar。这基本上是一个图形参数设置列表。
参数:vp
A Grid viewport object (or NULL).
一个网格视口对象(或NULL)。
参数:...
Arguments passed to pathGrob().
参数传递到pathGrob()。
Details
详情----------Details----------
Both functions create a path grob (a graphical object describing a path), but only grid.path draws the path (and then only if draw is TRUE).
这两个函数创建一个路径格罗(图形对象描述的路径),但是只有grid.path绘制路径(然后只有draw是TRUE)。
A path is like a polygon except that the former can contain holes, as interpreted by the fill rule; these fill a region if the path border encircles it an odd or non-zero number of times, respectively.
路径是一样,只是前者可以包含孔,填充规则解释的多边形,如果路径边界环绕奇次或非零数,分别填补了区域。
Not all graphics devices support this function: for example xfig and pictex do not.
并非所有的图形设备支持此功能:例如xfig的和pictex不要。
值----------Value----------
A grob object.
一个GROB对象。
作者(S)----------Author(s)----------
Paul Murrell
参见----------See Also----------
Grid, viewport
电网,viewport
举例----------Examples----------
pathSample <- function(x, y, rule, gp = gpar()) {
if (is.na(rule))
grid.path(x, y, id = rep(1:2, each = 4), gp = gp)
else
grid.path(x, y, id = rep(1:2, each = 4), rule = rule, gp = gp)
if (!is.na(rule))
grid.text(paste("Rule:", rule), y = 0, just = "bottom")
}
pathTriplet <- function(x, y, title) {
pushViewport(viewport(height = 0.9, layout = grid.layout(1, 3),
gp = gpar(cex = .7)))
grid.rect(y = 1, height = unit(1, "char"), just = "top",
gp = gpar(col = NA, fill = "grey"))
grid.text(title, y = 1, just = "top")
pushViewport(viewport(layout.pos.col = 1))
pathSample(x, y, rule = "winding",
gp = gpar(fill = "grey"))
popViewport()
pushViewport(viewport(layout.pos.col = 2))
pathSample(x, y, rule = "evenodd",
gp = gpar(fill = "grey"))
popViewport()
pushViewport(viewport(layout.pos.col = 3))
pathSample(x, y, rule = NA)
popViewport()
popViewport()
}
pathTest <- function() {
grid.newpage()
pushViewport(viewport(layout = grid.layout(5, 1)))
pushViewport(viewport(layout.pos.row = 1))
pathTriplet(c(.1, .1, .9, .9, .2, .2, .8, .8),
c(.1, .9, .9, .1, .2, .8, .8, .2),
"Nested rectangles, both clockwise")
popViewport()
pushViewport(viewport(layout.pos.row = 2))
pathTriplet(c(.1, .1, .9, .9, .2, .8, .8, .2),
c(.1, .9, .9, .1, .2, .2, .8, .8),
"Nested rectangles, outer clockwise, inner anti-clockwise")
popViewport()
pushViewport(viewport(layout.pos.row = 3))
pathTriplet(c(.1, .1, .4, .4, .6, .9, .9, .6),
c(.1, .4, .4, .1, .6, .6, .9, .9),
"Disjoint rectangles")
popViewport()
pushViewport(viewport(layout.pos.row = 4))
pathTriplet(c(.1, .1, .6, .6, .4, .4, .9, .9),
c(.1, .6, .6, .1, .4, .9, .9, .4),
"Overlapping rectangles, both clockwise")
popViewport()
pushViewport(viewport(layout.pos.row = 5))
pathTriplet(c(.1, .1, .6, .6, .4, .9, .9, .4),
c(.1, .6, .6, .1, .4, .4, .9, .9),
"Overlapping rectangles, one clockwise, other anti-clockwise")
popViewport()
popViewport()
}
pathTest()
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|