xspline(graphics)
xspline()所属R语言包:graphics
Draw an X-spline
画一个X-样条
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Draw an X-spline, a curve drawn relative to control points.
绘制一个X-样条曲线,得出相对控制点。
用法----------Usage----------
xspline(x, y = NULL, shape = 0, open = TRUE, repEnds = TRUE,
draw = TRUE, border = par("fg"), col = NA, ...)
参数----------Arguments----------
参数:x,y
vectors containing the coordinates of the vertices of the polygon. See xy.coords for alternatives.
多边形的顶点坐标的向量。看到xy.coords替代品。
参数: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 an open or a closed shape.
一个逻辑值,指示是否花键是一个开放或闭合的形状。
参数:repEnds
For open X-splines, a logical value indicating whether the first and last control points should be replicated for drawing the curve. Ignored for closed X-splines.
打开X-样条,一个逻辑值,指示是否应绘制曲线复制的第一个和最后一个控制点。忽视了封闭的X线花键。
参数:draw
logical: should the X-spline be drawn? If false, a set of line segments to draw the curve is returned, and nothing is drawn.
逻辑:应在X-样条绘制?如果为false,则返回一组线段来绘制曲线,没有绘制。
参数:border
the color to draw the curve. Use border = NA to omit borders.
颜色绘制曲线。使用border = NA省略边框。
参数:col
the color for filling the shape. The default, NA, is to leave unfilled.
填充形状的颜色。默认情况下,NA,是离开悬空。
参数:...
graphical parameters such as lty, xpd, lend, ljoin and lmitre can be given as arguments.
如lty,xpd,lend,ljoin和lmitre图形参数可以作为参数。
Details
详情----------Details----------
An X-spline 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.
得出相对控制点的X-样条线。对于每一个控制点,线可通过(插值)的控制点,或它可能只接近(近似)的控制点的行为是由每个控制点的形状参数确定。
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 X-splines, the start and end control points must have a shape of 0 (and non-zero values are silently converted to zero).
打开X-样条,开始和结束的控制点必须有一个形状0(默默非零值转换到零)。
For open X-splines, by default the start and end control points are 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.
打开X-样条,默认的开始和结束的控制点被复制前绘制曲线。 (插值或近似)的第二和第三,每个组4个控制点,所以此默认行为,确保所产生的曲线开始在您所指定的第一个控制点,并在最后一个控制点之间绘制一条曲线。默认行为可以通过repEnds论点被关闭。
值----------Value----------
If draw = TRUE, NULL otherwise a list with elements x and y which could be passed to lines, polygon and so on.
如果draw = TRUE,NULL否则的元素的列表x和y可以通过lines,polygon等。
Invisible in both cases.
在这两种情况下不可见的。
注意----------Note----------
Two-dimensional splines need to be created in an isotropic coordinate system. Device coordinates are used (with an anisotropy correction if needed.)
二维样条需要在各向同性坐标系创建。设备坐标(如果需要的各向异性校正。)
参考文献----------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----------
polygon.
polygon。
par for how to specify colors.
par如何指定颜色。
举例----------Examples----------
## based on examples in ?grid.xspline[#例子的基础上?grid.xspline]
xsplineTest <- function(s, open = TRUE,
x = c(1,1,3,3)/4,
y = c(1,3,3,1)/4, ...) {
plot(c(0,1), c(0,1), type="n", axes=FALSE, xlab="", ylab="")
points(x, y, pch=19)
xspline(x, y, s, open, ...)
text(x+0.05*c(-1,-1,1,1), y+0.05*c(-1,1,1,-1), s)
}
op <- par(mfrow=c(3,3), mar=rep(0,4), oma=c(0,0,2,0))
xsplineTest(c(0, -1, -1, 0))
xsplineTest(c(0, -1, 0, 0))
xsplineTest(c(0, -1, 1, 0))
xsplineTest(c(0, 0, -1, 0))
xsplineTest(c(0, 0, 0, 0))
xsplineTest(c(0, 0, 1, 0))
xsplineTest(c(0, 1, -1, 0))
xsplineTest(c(0, 1, 0, 0))
xsplineTest(c(0, 1, 1, 0))
title("Open X-splines", outer=TRUE)
par(mfrow=c(3,3), mar=rep(0,4), oma=c(0,0,2,0))
xsplineTest(c(0, -1, -1, 0), FALSE, col="grey80")
xsplineTest(c(0, -1, 0, 0), FALSE, col="grey80")
xsplineTest(c(0, -1, 1, 0), FALSE, col="grey80")
xsplineTest(c(0, 0, -1, 0), FALSE, col="grey80")
xsplineTest(c(0, 0, 0, 0), FALSE, col="grey80")
xsplineTest(c(0, 0, 1, 0), FALSE, col="grey80")
xsplineTest(c(0, 1, -1, 0), FALSE, col="grey80")
xsplineTest(c(0, 1, 0, 0), FALSE, col="grey80")
xsplineTest(c(0, 1, 1, 0), FALSE, col="grey80")
title("Closed X-splines", outer=TRUE)
par(op)
x <- sort(stats::rnorm(5))
y <- sort(stats::rnorm(5))
plot(x, y, pch=19)
res <- xspline(x, y, 1, draw=FALSE)
lines(res)
## the end points may be very close together,[#终点可能会非常接近,]
## so use last few for direction[#所以用过去数方向]
nr <- length(res$x)
arrows(res$x[1], res$y[1], res$x[4], res$y[4], code=1, length=0.1)
arrows(res$x[nr-3], res$y[nr-3], res$x[nr], res$y[nr],
code = 2, length = 0.1)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|