layout(graphics)
layout()所属R语言包:graphics
Specifying Complex Plot Arrangements
指定复杂的图安排
译者:生物统计家园网 机器人LoveR
描述----------Description----------
layout divides the device up into as many rows and columns as there are in matrix mat, with the column-widths and the row-heights specified in the respective arguments.
layout分成许多行和列的设备,因为在矩阵mat,列在各自的参数中指定的宽度和行高度。
用法----------Usage----------
layout(mat, widths = rep(1, ncol(mat)),
heights = rep(1, nrow(mat)), respect = FALSE)
layout.show(n = 1)
lcm(x)
参数----------Arguments----------
参数:mat
a matrix object specifying the location of the next N figures on the output device. Each value in the matrix must be 0 or a positive integer. If N is the largest positive integer in the matrix, then the integers {1, …, N-1} must also appear at least once in the matrix.
一个矩阵对象指定未来N输出设备上的数据的位置。矩阵中的每个值必须是0或正整数。如果N是全球最大的正整数矩阵,然后整数{1, …, N-1}的也必须出现在矩阵至少一次。
参数:widths
a vector of values for the widths of columns on the device. Relative widths are specified with numeric values. Absolute widths (in centimetres) are specified with the lcm() function (see examples).
设备上的列的宽度值的向量。相对宽度指定数值。 lcm()功能(见例子)指定绝对宽度(厘米)。
参数:heights
a vector of values for the heights of rows on the device. Relative and absolute heights can be specified, see widths above.
设备上的行的高度值向量。可以指定相对和绝对的高度,看到widths以上。
参数:respect
either a logical value or a matrix object. If the latter, then it must have the same dimensions as mat and each value in the matrix must be either 0 or 1.
无论是一个逻辑值或一个矩阵对象。如果是后者,那么它必须具有相同的尺寸mat矩阵中的每个值必须要么0或1。
参数:n
number of figures to plot.
数量积的数字。
参数:x
a dimension to be interpreted as a number of centimetres.
被解释为一个维度厘米。
Details
详情----------Details----------
Figure i is allocated a region composed from a subset of these rows and columns, based on the rows and columns in which i occurs in mat.
图i分配从这些行和列的子集,基于在imat发生的行和列组成的区域。
The respect argument controls whether a unit column-width is the same physical measurement on the device as a unit row-height.
respect参数控制是否单位列宽度是相同的设备上的物理测量作为一个单元行的高度。
There is a limit (currently 50) for the numbers of rows and columns in the layout, and also for the total number of cells (500).
有一个布局中的行和列的数量限制(目前为50个),也为单元总数(500)。
layout.show(n) plots (part of) the current layout, namely the outlines of the next n figures.
layout.show(n)图(部分)当前的布局,即未来n数字的轮廓。
lcm is a trivial function, to be used as the interface for specifying absolute dimensions for the widths and heights arguments of layout().
lcm是一个平凡的功能,接口用于指定widths和heightslayout()参数的绝对尺寸。
值----------Value----------
layout returns the number of figures, N, see above.
layout返回的数字,N,见上面。
警告----------Warnings----------
These functions are totally incompatible with the other mechanisms for arranging plots on a device: par(mfrow), par(mfcol) and split.screen.
这些功能是完全不与其他机制的安排在设备上图:par(mfrow),par(mfcol)和split.screen。
作者(S)----------Author(s)----------
Paul R. Murrell
参考文献----------References----------
Journal of Computational and Graphical Statistics, 8, 121-134.
参见----------See Also----------
par with arguments mfrow, mfcol, or mfg.
par参数mfrow,mfcol或mfg。
举例----------Examples----------
def.par <- par(no.readonly = TRUE) # save default, for resetting...[保存默认情况下,重设...]
## divide the device into two rows and two columns[#设备分为两行和两列]
## allocate figure 1 all of row 1[#分配图1行1]
## allocate figure 2 the intersection of column 2 and row 2[#分配图2中的第2栏和第2行的路口。]
layout(matrix(c(1,1,0,2), 2, 2, byrow = TRUE))
## show the regions that have been allocated to each plot[#显示已分配给每个小区的区域。]
layout.show(2)
## divide device into two rows and two columns[#分成两行两列的设备]
## allocate figure 1 and figure 2 as above[#分配如上图1和图2]
## respect relations between widths and heights[#尊重宽度和高度之间的关系。]
nf <- layout(matrix(c(1,1,0,2), 2, 2, byrow=TRUE), respect=TRUE)
layout.show(nf)
## create single figure which is 5cm square[#创建一个单一的数字为5cm平方米]
nf <- layout(matrix(1), widths=lcm(5), heights=lcm(5))
layout.show(nf)
##-- Create a scatterplot with marginal histograms -----[# - 创建一个散点图与边缘直方图-----]
x <- pmin(3, pmax(-3, stats::rnorm(50)))
y <- pmin(3, pmax(-3, stats::rnorm(50)))
xhist <- hist(x, breaks=seq(-3,3,0.5), plot=FALSE)
yhist <- hist(y, breaks=seq(-3,3,0.5), plot=FALSE)
top <- max(c(xhist$counts, yhist$counts))
xrange <- c(-3,3)
yrange <- c(-3,3)
nf <- layout(matrix(c(2,0,1,3),2,2,byrow=TRUE), c(3,1), c(1,3), TRUE)
layout.show(nf)
par(mar=c(3,3,1,1))
plot(x, y, xlim=xrange, ylim=yrange, xlab="", ylab="")
par(mar=c(0,3,1,1))
barplot(xhist$counts, axes=FALSE, ylim=c(0, top), space=0)
par(mar=c(3,0,1,1))
barplot(yhist$counts, axes=FALSE, xlim=c(0, top), space=0, horiz=TRUE)
par(def.par)#- reset to default[ - 重置为默认]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|