grid.xspline(grid)
grid.xspline()所属R语言包:grid
Draw an Xspline
绘制1 Xspline
译者:生物统计家园网 机器人LoveR
描述----------Description----------
These functions create and draw an xspline, a curve drawn relative to control points.
这些函数创建和绘制xspline,曲线绘制与控制点。
用法----------Usage----------
grid.xspline(...)
xsplineGrob(x = c(0, 0.5, 1, 0.5), y = c(0.5, 1, 0.5, 0),
id = NULL, id.lengths = NULL,
default.units = "npc",
shape = 0, open = TRUE, arrow = NULL, repEnds = TRUE,
name = NULL, gp = gpar(), vp = NULL)
参数----------Arguments----------
参数:x
A numeric vector or unit object specifying x-locations of spline control points.
一个数值向量或单位指定X-样条曲线控制点位置的对象。
参数:y
A numeric vector or unit object specifying y-locations of spline control points.
一个数值向量或单位对象指定样条曲线控制点的Y-位置。
参数:id
A numeric vector used to separate locations in x and y into multiple xsplines. All locations with the same id belong to the same xspline.
一个数值向量使用分开x和y成多个xsplines的位置。所有具有相同的id位置属于相同xspline。“
参数:id.lengths
A numeric vector used to separate locations in x and y into multiple xspline. Specifies consecutive blocks of locations which make up separate xsplines.
一个数值向量使用分开x和y成多个xspline的位置。指定地点连续的块弥补单独xsplines的。
参数:default.units
A string indicating the default units to use if x or y are only given as numeric vectors.
一个字符串,指示的默认单位使用,如果x或y只为数字向量。
参数:shape
A numeric vector of values between -1 and 1, which control the shape of the spline relative to the control points.
-1和1之间的值,从而控制相对控制点的样条的形状的一个数值向量。
参数:open
A logical value indicating whether the spline is a line or a closed shape.
一个逻辑值,该值指示是否样条线是一条线或一个封闭的形状。
参数:arrow
A list describing arrow heads to place at either end of the xspline, as produced by the arrow function.
描述箭头元首将任xspline结束,arrow函数列表。
参数:repEnds
A logical value indicating whether the first and last control points should be replicated for drawing the curve (see Details below).
一个逻辑值,绘制曲线的第一个和最后一个控制点是否应被复制(详见下文)。
参数: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 to be passed to xsplineGrob.
参数被传递到xsplineGrob。
Details
详情----------Details----------
Both functions create an xspline grob (a graphical object describing an xspline), but only grid.xspline draws the xspline.
这两个函数创建一个xspline,GROB(图形对象描述xspline),但,grid.xspline投篮xspline。
An xspline is a line drawn relative to control points. For each control point, the line may pass through (interpolate) the control point or it may only approach (approximate) the control point; the behaviour is determined by a shape parameter for each control point.
在一个xspline是画线相对控制点。对于每一个控制点,线可通过(插值)的控制点,或它可能只接近(近似)的控制点的行为是由每个控制点的形状参数确定。
If the shape parameter is greater than zero, the spline approximates the control points (and is very similar to a cubic B-spline when the shape is 1). If the shape parameter is less than zero, the spline interpolates the control points (and is very similar to a Catmull-Rom spline when the shape is -1). If the shape parameter is 0, the spline forms a sharp corner at that control point.
如果形状参数大于零,样条逼近控制点(立方B样条的形状是1时,是非常相似)。如果形状参数小于零,样条插值控制点(和非常相似时的形状是-1到的Catmull-Rom样条)。如果形状参数为0,样条线形成一个尖角,控制点。
For open xsplines, the start and end control points must have a shape of 0 (and non-zero values are silently converted to zero without warning).
开始和结束的控制点对于开放xsplines,必须有一个形状0(非零值默默没有警告的情况下转换到零)。
For open xsplines, by default the start and end control points are actually replicated before the curve is drawn. A curve is drawn between (interpolating or approximating) the second and third of each set of four control points, so this default behaviour ensures that the resulting curve starts at the first control point you have specified and ends at the last control point. The default behaviour can be turned off via the repEnds argument, in which case the curve that is drawn starts (approximately) at the second control point and ends (approximately) at the first and second-to-last control point.
默认情况下,对于开放xsplines,开始和结束的控制点实际上是复制之前绘制的曲线。 (插值或近似)的第二和第三,每个组4个控制点,所以此默认行为,确保所产生的曲线开始在您所指定的第一个控制点,并在最后一个控制点之间绘制一条曲线。关闭默认行为可以通过repEnds参数,在这种情况下,在第二个控制点和结束(约)绘制开始(约)在第一和第二个到最后的控制点的曲线。
The repEnds argument is ignored for closed xsplines.
repEnds参数将被忽略封闭xsplines。
Missing values are not allowed for x and y (i.e., it is not valid for a control point to be missing).
遗漏值是不允许x和y(即,它是不是有效的控制点的丢失)。
For closed xsplines, a curve is automatically drawn between the final control point and the initial control point.
对于闭xsplines,自动绘制曲线之间的最终控制点和初始控制点。
值----------Value----------
A grob object.
一个GROB对象。
参考文献----------References----------
"X-splines : A Spline Model Designed for the End User", in Proceedings of SIGGRAPH 95, pp. 377–386. http://dept-info.labri.fr/~schlick/DOC/sig1.html
参见----------See Also----------
Grid, viewport, arrow.
电网,viewport,arrow。
xspline.
xspline。
举例----------Examples----------
x <- c(0.25, 0.25, 0.75, 0.75)
y <- c(0.25, 0.75, 0.75, 0.25)
xsplineTest <- function(s, i, j, open) {
pushViewport(viewport(layout.pos.col=j, layout.pos.row=i))
grid.points(x, y, default.units="npc", pch=16, size=unit(2, "mm"))
grid.xspline(x, y, shape=s, open=open, gp=gpar(fill="grey"))
grid.text(s, gp=gpar(col="grey"),
x=unit(x, "npc") + unit(c(-1, -1, 1, 1), "mm"),
y=unit(y, "npc") + unit(c(-1, 1, 1, -1), "mm"),
hjust=c(1, 1, 0, 0),
vjust=c(1, 0, 0, 1))
popViewport()
}
pushViewport(viewport(width=.5, x=0, just="left",
layout=grid.layout(3, 3, respect=TRUE)))
pushViewport(viewport(layout.pos.row=1))
grid.text("Open Splines", y=1, just="bottom")
popViewport()
xsplineTest(c(0, -1, -1, 0), 1, 1, TRUE)
xsplineTest(c(0, -1, 0, 0), 1, 2, TRUE)
xsplineTest(c(0, -1, 1, 0), 1, 3, TRUE)
xsplineTest(c(0, 0, -1, 0), 2, 1, TRUE)
xsplineTest(c(0, 0, 0, 0), 2, 2, TRUE)
xsplineTest(c(0, 0, 1, 0), 2, 3, TRUE)
xsplineTest(c(0, 1, -1, 0), 3, 1, TRUE)
xsplineTest(c(0, 1, 0, 0), 3, 2, TRUE)
xsplineTest(c(0, 1, 1, 0), 3, 3, TRUE)
popViewport()
pushViewport(viewport(width=.5, x=1, just="right",
layout=grid.layout(3, 3, respect=TRUE)))
pushViewport(viewport(layout.pos.row=1))
grid.text("Closed Splines", y=1, just="bottom")
popViewport()
xsplineTest(c(-1, -1, -1, -1), 1, 1, FALSE)
xsplineTest(c(-1, -1, 0, -1), 1, 2, FALSE)
xsplineTest(c(-1, -1, 1, -1), 1, 3, FALSE)
xsplineTest(c( 0, 0, -1, 0), 2, 1, FALSE)
xsplineTest(c( 0, 0, 0, 0), 2, 2, FALSE)
xsplineTest(c( 0, 0, 1, 0), 2, 3, FALSE)
xsplineTest(c( 1, 1, -1, 1), 3, 1, FALSE)
xsplineTest(c( 1, 1, 0, 1), 3, 2, FALSE)
xsplineTest(c( 1, 1, 1, 1), 3, 3, FALSE)
popViewport()
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|