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

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

[复制链接]
发表于 2012-2-17 09:47:54 | 显示全部楼层 |阅读模式
viewport(grid)
viewport()所属R语言包:grid

                                        Create a Grid Viewport
                                         创建一个网格视

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

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

These functions create viewports, which describe rectangular regions on a graphics device and define a number of coordinate systems within those regions.
这些功能创建视口,描述图形设备上的矩形区域,并确定在这些区域内的坐标系统。


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


viewport(x = unit(0.5, "npc"), y = unit(0.5, "npc"),
         width = unit(1, "npc"), height = unit(1, "npc"),
         default.units = "npc", just = "centre",
         gp = gpar(), clip = "inherit",
         xscale = c(0, 1), yscale = c(0, 1),
         angle = 0,
         layout = NULL,
         layout.pos.row = NULL, layout.pos.col = NULL,
         name = NULL)
vpList(...)
vpStack(...)
vpTree(parent, children)



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

参数:x
A numeric vector or unit object specifying x-location.
一个数值向量或单位对象指定的x位置。


参数:y
A numeric vector or unit object specifying y-location.
指定一个数值向量或单位对象的y位置。


参数:width
A numeric vector or unit object specifying width.
一个数值向量或指定单位的对象宽度。


参数:height
A numeric vector or unit object specifying height.
一个数值向量或指定单位的对象高度。


参数:default.units
A string indicating the default units to use if x, y, width, or height are only given as numeric vectors.   
只给一个字符串,表示如果x,y,width或height使用的默认单位为数字向量。


参数:just
A string or numeric vector specifying the justification of the viewport relative to its (x, y) location.  If there are two values, the first value specifies horizontal justification and the second value specifies vertical justification.  Possible string values are: "left", "right", "centre", "center", "bottom", and "top".  For numeric values, 0 means left alignment and 1 means right alignment.  
一个字符串或数字向量,它的位置(X,Y)指定视口的相对理由。如果有两个值,第一个值指定水平的理由,第二个值指定垂直对齐。可能的字符串值是:"left","right","centre","center","bottom","top"。对于数值,0表示左对齐,右对齐1手段。


参数: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。这基本上是一个图形参数设置列表。


参数:clip
One of "on", "inherit", or "off", indicating whether to clip to the extent of this viewport, inherit the clipping region from the parent viewport, or turn clipping off altogether. For back-compatibility, a logical value of TRUE corresponds to "on" and FALSE corresponds to "inherit".
一个"on","inherit"或"off",说明是否夹到这个视程度,继承父视口裁剪区域,或打开裁剪完全关闭。为了向后兼容性,逻辑值的TRUE对应"on"和FALSE"inherit"。


参数:xscale
A numeric vector of length two indicating the minimum and maximum on the x-scale.
一个长度为2的数字矢量显示上最大和最小的X规模。


参数:yscale
A numeric vector of length two indicating the minimum and maximum on the y-scale.
一个长度表明在y规模最大和最小的两个数字向量。


参数:angle
A numeric value indicating the angle of rotation of the viewport.  Positive values indicate the amount of rotation, in degrees, anticlockwise from the positive x-axis.
一个数值,表示视口的旋转角度。正值表示金额度旋转,从正x轴逆时针。


参数:layout
A Grid layout object which splits the viewport into subregions.
网格布局对象分成次区域的视口。


参数:layout.pos.row
A numeric vector giving the rows occupied by this viewport in its parent's layout.
一个数值向量,给予行占领这个视其母公司的布局。


参数:layout.pos.col
A numeric vector giving the columns occupied by this viewport in its parent's layout.
一个数值向量,让这个视占领列在其父母的布局。


参数:name
A character value to uniquely identify the viewport once it has been pushed onto the viewport tree.   
一个字符值唯一标识视口,一旦它被推到视口中的树。


参数:...
Any number of grid viewport objects.
任何数量的网格视口对象。


参数:parent
A grid viewport object.
网格视口对象。


参数:children
A vpList object.
一个vpList对象。


Details

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

The location and size of a viewport are relative to the coordinate systems defined by the viewport's parent (either a graphical device or another viewport).  The location and size can be specified in a very flexible way by specifying them with unit objects. When specifying the location of a viewport, specifying both layout.pos.row and layout.pos.col as NULL indicates that the viewport ignores its parent's layout and specifies its own location and size (via its locn).  If only one of layout.pos.row and layout.pos.col is NULL, this means occupy ALL of the appropriate row(s)/column(s).  For example, layout.pos.row = 1 and layout.pos.col = NULL means occupy all of row 1.  Specifying non-NULL values for both layout.pos.row and layout.pos.col means occupy the intersection of the appropriate rows and columns.  If a vector of length two is specified for layout.pos.row or layout.pos.col, this indicates a range of rows or columns to occupy.  For example, layout.pos.row = c(1, 3) and layout.pos.col = c(2, 4) means occupy cells in the intersection of rows 1, 2, and 3, and columns, 2, 3, and 4.
视口的位置和大小都是相对的定义视口的父(无论是图形设备或其他视口)坐标系统。的位置和大小,可以指定在一个非常灵活的方式,由指定单位对象。当指定的视口的位置,指定两个layout.pos.row和layout.pos.colNULL表示视口忽略了其母公司的布局,并指定其自己的位置和大小(通过其locn )。如果只有一个layout.pos.row和layout.pos.col是NULL,这意味着占据相应的行(S)/列(S)。例如,layout.pos.row = 1和layout.pos.col = NULL手段占据第1行所有。指定非NULL值都layout.pos.row和layout.pos.col意味着占据适当的行和列的交叉点。如果被指定为layout.pos.row或layout.pos.col一个长度为2的向量,这表明占据的行或列的范围。例如,layout.pos.row = c(1, 3)和layout.pos.col = c(2, 4)手段占据单元在路口行1,2,3,列,2,3和4。

Clipping obeys only the most recent viewport clip setting. For example, if you clip to viewport1, then clip to viewport2, the clipping region is determined wholly by viewport2, the size and shape of viewport1 is irrelevant (until viewport2 is popped of course).
裁剪服从只有最近视口夹设置。例如,如果你夹到viewport1,然后夹viewport2,裁剪区域完全由viewport2决定,是无关紧要的大小和形状viewport1(直到viewport2当然弹出)。

If a viewport is rotated (because of its own angle setting or because it is within another viewport which is rotated) then the clip flag is ignored.
如果一个视口于angle旋转(因为自己的clip设置或因为它是在另一个视旋转),然后标志被忽略。

Viewport names need not be unique.  When pushed, viewports sharing the same parent must have unique names, which means that if you push a viewport with the same name as an existing viewport, the existing viewport will be replaced in the viewport tree. A viewport name can be any string, but grid uses the reserved name "ROOT" for the top-level viewport.  Also, when specifying a viewport name in downViewport and seekViewport, it is possible to provide a viewport path, which consists of several names concatenated using the separator  (currently :.  Consequently, it is not advisable to use this separator in viewport names.
视口的名称不必是唯一的。当推,视口共享同一母公司必须有独特的名字,这意味着,如果你推相同的名称与现有的视口视口,现有的视口将在视口中树取代。视口的名称可以是任何字符串,但电网保留的名称"ROOT"使用顶级的视口。此外,指定视口的名称时,downViewport和seekViewport,它可以提供一个视口的路径,这几个名字组成级联使用的分隔符(目前::)。因此,它是不宜使用视口的名称分隔。

The viewports in a vpList are pushed in parallel.  The viewports in a vpStack are pushed in series.  When a vpTree is pushed, the parent is pushed first, then the children are pushed in parallel.
在视口中vpList在平行推。在视口中vpStack推系列。 vpTree推,父先推,然后孩子们在平行推。


值----------Value----------

An R object of class viewport.
类viewportR对象。


作者(S)----------Author(s)----------


Paul Murrell



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

Grid, pushViewport, popViewport, downViewport, seekViewport, upViewport, unit, grid.layout, grid.show.layout.
电网,pushViewport,popViewport,downViewport,seekViewport,upViewport,unit,grid.layout,grid.show.layout。


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


# Diagram of a sample viewport[样本“视口中图]
grid.show.viewport(viewport(x=0.6, y=0.6,
                   w=unit(1, "inches"), h=unit(1, "inches")))
# Demonstrate viewport clipping[演示视口剪裁]
clip.demo <- function(i, j, clip1, clip2) {
  pushViewport(viewport(layout.pos.col=i,
                         layout.pos.row=j))
  pushViewport(viewport(width=0.6, height=0.6, clip=clip1))
  grid.rect(gp=gpar(fill="white"))
  grid.circle(r=0.55, gp=gpar(col="red", fill="pink"))
  popViewport()
  pushViewport(viewport(width=0.6, height=0.6, clip=clip2))
  grid.polygon(x=c(0.5, 1.1, 0.6, 1.1, 0.5, -0.1, 0.4, -0.1),
               y=c(0.6, 1.1, 0.5, -0.1, 0.4, -0.1, 0.5, 1.1),
               gp=gpar(col="blue", fill="light blue"))
  popViewport(2)
}

grid.newpage()
grid.rect(gp=gpar(fill="grey"))
pushViewport(viewport(layout=grid.layout(2, 2)))
clip.demo(1, 1, FALSE, FALSE)
clip.demo(1, 2, TRUE, FALSE)
clip.demo(2, 1, FALSE, TRUE)
clip.demo(2, 2, TRUE, TRUE)
popViewport()
# Demonstrate turning clipping off[展示转向裁剪关闭]
grid.newpage()
pushViewport(viewport(w=.5, h=.5, clip="on"))
grid.rect()
grid.circle(r=.6, gp=gpar(lwd=10))
pushViewport(viewport(clip="inherit"))
grid.circle(r=.6, gp=gpar(lwd=5, col="grey"))
pushViewport(viewport(clip="off"))
grid.circle(r=.6)
popViewport(3)
# Demonstrate vpList, vpStack, and vpTree[展示vpList,vpStack,vpTree]
grid.newpage()
tree <- vpTree(viewport(w=0.8, h=0.8, name="A"),
               vpList(vpStack(viewport(x=0.1, y=0.1, w=0.5, h=0.5,
                                       just=c("left", "bottom"), name="B"),
                              viewport(x=0.1, y=0.1, w=0.5, h=0.5,
                                       just=c("left", "bottom"), name="C"),
                              viewport(x=0.1, y=0.1, w=0.5, h=0.5,
                                       just=c("left", "bottom"), name="D")),
                      viewport(x=0.5, w=0.4, h=0.9,
                               just="left", name="E")))
pushViewport(tree)
for (i in LETTERS[1:5]) {
  seekViewport(i)
  grid.rect()
  grid.text(current.vpTree(FALSE),
            x=unit(1, "mm"), y=unit(1, "npc") - unit(1, "mm"),
            just=c("left", "top"),
            gp=gpar(fontsize=8))
}

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 04:08 , Processed in 0.025453 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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