找回密码
 注册
查看: 6093|回复: 0

R语言:contour()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 19:33:48 | 显示全部楼层 |阅读模式
contour(graphics)
contour()所属R语言包:graphics

                                        Display Contours
                                         显示轮廓

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Create a contour plot, or add contour lines to an existing plot.
创建等高线图,等高线或增加现有的图。


用法----------Usage----------


contour(x, ...)

## Default S3 method:[默认方法]
contour(x = seq(0, 1, length.out = nrow(z)),
        y = seq(0, 1, length.out = ncol(z)),
        z,
        nlevels = 10, levels = pretty(zlim, nlevels),
        labels = NULL,
        xlim = range(x, finite = TRUE),
        ylim = range(y, finite = TRUE),
        zlim = range(z, finite = TRUE),
        labcex = 0.6, drawlabels = TRUE, method = "flattest",
        vfont, axes = TRUE, frame.plot = axes,
        col = par("fg"), lty = par("lty"), lwd = par("lwd"),
        add = FALSE, ...)



参数----------Arguments----------

参数:x,y
locations of grid lines at which the values in z are measured.  These must be in ascending order.  By default, equally spaced values from 0 to 1 are used.  If x is a list, its components x$x and x$y are used for x and y, respectively. If the list has component z this is used for z.
在网格线的位置中的值z测量。这些必须是升序。默认情况下,使用等距值从0到1。如果x是list,其成分x$x和x$y是用于x和y,分别。如果列表组件z用于z。


参数:z
a matrix containing the values to be plotted (NAs are allowed).  Note that x can be used instead of z for convenience.
矩阵包含值绘制(NA的允许)。注意x可以用来代替z为了方便。


参数:nlevels
number of contour levels desired iff levels is not supplied.
等高层次所需的IFF levels没有提供。


参数:levels
numeric vector of levels at which to draw contour lines.
数字向量在其中绘制等高线的水平。


参数:labels
a vector giving the labels for the contour lines.  If NULL then the levels are used as labels, otherwise this is coerced by as.character.
向量轮廓线的标签。如果NULL然后作为标签使用的水平,否则这是强迫as.character。


参数:labcex
cex for contour labelling.  This is an absolute size, not a multiple of par("cex").
cex轮廓标签。这是一个绝对的大小,而不是一个par("cex")的倍数。


参数:drawlabels
logical.  Contours are labelled if TRUE.
逻辑。如果TRUE轮廓标。


参数:method
character string specifying where the labels will be located. Possible values are "simple", "edge" and "flattest" (the default).  See the "Details" section.
字符串指定的标签将位于。可能的值是"simple","edge"和"flattest"(默认)。看到“详细资料”一节。


参数:vfont
if NULL, the current font family and face are used for the contour labels.  If a character vector of length 2 then Hershey vector fonts are used for the contour labels. The first element of the vector selects a typeface and the second element selects a fontindex (see text for more information). The default is NULL on graphics devices with high-quality rotation of text and c("sans serif", "plain") otherwise.
如果NULL,当前字体的家庭和面部轮廓标签使用。如果一个长度为2的特征向量,然后赫尔希用于矢量字体的轮廓标签。向量的第一个元素选择一个字体和第二个元素选择fontindex(见text更多的信息)。默认的是NULL高品质的文本和旋转c("sans serif", "plain")否则图形设备。


参数:xlim, ylim, zlim
x-, y- and z-limits for the plot.
X,Y,Z-积的限制。


参数:axes, frame.plot
logical indicating whether axes or a box should be drawn, see plot.default.
逻辑指示是否应制定轴或一个盒子,看到plot.default。


参数:col
color for the lines drawn.
画线的颜色。


参数:lty
line type for the lines drawn.
画线的线路类型。


参数:lwd
line width for the lines drawn.
画线的线宽。


参数:add
logical. If TRUE, add to a current plot.
逻辑。如果TRUE,添加到当前的图。


参数:...
additional arguments to plot.window, title, Axis and box, typically graphical parameters such as cex.axis.
额外的参数plot.window,title,Axis和box,通常图形的参数,如cex.axis。


Details

详情----------Details----------

contour is a generic function with only a default method in base R.
contour只有一个默认的方法是在基础R.泛型函数

The methods for positioning the labels on contours are "simple" (draw at the edge of the plot, overlaying the contour line), "edge" (draw at the edge of the plot, embedded in the contour line, with no labels overlapping) and "flattest" (draw on the flattest section of the contour, embedded in the contour line, with no labels overlapping).  The second and third may not draw a label on every contour line.
"simple"(画在小区边缘,重叠的轮廓线),"edge"(在边缘的图,在嵌入的轮廓线画,轮廓上的标签定位的方法没有标签重叠)和"flattest"(借鉴嵌入在轮廓线的平坦部分的轮廓,没有重叠的标签)。第二和第三个可能没有画上的每一个轮廓线的标签。

For information about vector fonts, see the help for text and Hershey.
对于矢量字体的信息,请参阅在text和Hershey的帮助下。

Notice that contour interprets the z matrix as a table of f(x[i], y[j]) values, so that the x axis corresponds to row number and the y axis to column number, with column 1 at the bottom, i.e. a 90 degree clockwise rotation of the conventional textual layout.
请注意contour解释zf(x[i], y[j])值作为表的矩阵,使X轴对应行数和Y轴的底部1列,列数,即传统的文本布局顺时针旋转90度。

Alternatively, use contourplot from the lattice package where the formula notation allows to use vectors x,y,z of the same length.
另外,使用contourplotlattice包formula符号允许使用向量x,y,z相同长度的。

There is limited control over the axes and frame as arguments col, lwd and lty refer to the contour lines (rather than being general graphical parameters).  For more control, add contours to a plot, or add axes and frame to a contour plot.
轴作为参数帧,有控制有限col,lwd和lty指的轮廓线(而不是一般的图形参数)。进行更多的控制,增加轮廓图,或添加到等高线图的轴和框架。


参考文献----------References----------

The New S Language. Wadsworth & Brooks/Cole.

参见----------See Also----------

options("max.contour.segments") for the maximal complexity of a single contour line.
options("max.contour.segments")最大的一个单一的轮廓线的复杂性。

contourLines, filled.contour for color-filled contours, contourplot (and levelplot) from package lattice. Further, image and the graphics demo which can be invoked as demo(graphics).
contourLines,filled.contour颜色填充轮廓,contourplot(levelplot)从包lattice。此外,image和图形演示,可以调用demo(graphics)。


举例----------Examples----------


require(grDevices) # for colours[对色彩]
x <- -6:16
op <- par(mfrow = c(2, 2))
contour(outer(x, x), method = "edge", vfont = c("sans serif", "plain"))
z <- outer(x, sqrt(abs(x)), FUN = "/")
image(x, x, z)
contour(x, x, z, col = "pink", add = TRUE, method = "edge",
        vfont = c("sans serif", "plain"))
contour(x, x, z, ylim = c(1, 6), method = "simple", labcex = 1)
contour(x, x, z, ylim = c(-6, 6), nlev = 20, lty = 2, method = "simple")
par(op)

## Persian Rug Art:[#波斯地毯的艺术:]
x <- y <- seq(-4*pi, 4*pi, len = 27)
r <- sqrt(outer(x^2, y^2, "+"))
opar <- par(mfrow = c(2, 2), mar = rep(0, 4))
for(f in pi^(0:3))
  contour(cos(r^2)*exp(-r/f),
          drawlabels = FALSE, axes = FALSE, frame = TRUE)

rx <- range(x <- 10*1:nrow(volcano))
ry <- range(y <- 10*1:ncol(volcano))
ry <- ry + c(-1,1) * (diff(rx) - diff(ry))/2
tcol <- terrain.colors(12)
par(opar); opar <- par(pty = "s", bg = "lightcyan")
plot(x = 0, y = 0,type = "n", xlim = rx, ylim = ry, xlab = "", ylab = "")
u <- par("usr")
rect(u[1], u[3], u[2], u[4], col = tcol[8], border = "red")
contour(x, y, volcano, col = tcol[2], lty = "solid", add = TRUE,
        vfont = c("sans serif", "plain"))
title("A Topographic Map of Maunga Whau", font = 4)
abline(h = 200*0:4, v = 200*0:4, col = "lightgray", lty = 2, lwd = 0.1)

## contourLines produces the same contour lines as contour[#contourLines生产相同的轮廓线为轮廓]
line.list <- contourLines(x, y, volcano)
plot(x = 0, y = 0,type = "n", xlim = rx, ylim = ry, xlab = "", ylab = "")
u <- par("usr")
rect(u[1], u[3], u[2], u[4], col = tcol[8], border = "red")
contour(x, y, volcano, col = tcol[2], lty = "solid", add = TRUE,
             vfont = c("sans serif", "plain"))
templines <- function(clines) {
  lines(clines[[2]], clines[[3]])
}
invisible(lapply(line.list, templines))
par(opar)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-24 16:45 , Processed in 0.030119 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表