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

R语言 treemap包 tmPlot()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-1 11:50:51 | 显示全部楼层 |阅读模式
tmPlot(treemap)
tmPlot()所属R语言包:treemap

                                        Create treemap
                                         创建树状图

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

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

Create treemap
创建树状图


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


  tmPlot(dtf, index, vSize, vColor = NULL, type = "value",
    title = NA, subtitle = NA, algorithm = "pivotSize",
    sortID = "-size", palette = NA, range = NA,
    vColorRange = NULL, fontsize.title = 14,
    fontsize.labels = 11, fontsize.legend = 12,
    lowerbound.cex.labels = 0.4, inflate.labels = FALSE,
    bg.labels = ifelse(type %in% c("value", "linked", "categorical"), "#CCCCCCAA", NA),
    force.print.labels = FALSE,
    position.legend = ifelse(type %in% c("categorical", "index"), "right", ifelse(type == "linked", "none", "bottom")),
    aspRatio = NA, na.rm = FALSE)



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

参数:dtf
a data.frame. Required.
数据框。必需的。


参数:index
vector containing the column names in dtf that contain the aggregation indices. Required.
向量中的列名dtf包含聚集索引。必需的。


参数:vSize
name of the variable that determines the sizes of the rectangles. For small multiples, a vector of variable names (one for each treemap) should be given. Required.
名称的变量,确定的矩形的大小。对于小的倍数,一个向量的变量名(其中一个为每个树形图)应给予。必需的。


参数:vColor
name of the variable that, in combination with type, determines the colors of the rectangles. The variable can be scaled by the addition of "*<scale factor>" or "/<scale factor>". For small multiples, a vector of variable names (one for each treemap) should be given.
名称的变量,在搭配type,确定的矩形的颜色。该变量可以通过添加“* <scale factor>”或“/ <scale factor>”缩放。对于小的倍数,一个向量的变量名(其中一个为每个树形图)应给予。


参数:type
the type of the treemap:     
的树形图的类型:

"value":the vColor-variable is directly mapped to a color palette (by default Brewer's diverging color palette "RdBu").  
"value":vColor,变量直接映射到一个调色板(默认啤酒不同的颜色调色板“RdBu”)。

"comp":colors indicate change of the vSize-variable with respect to the vColor-variable in percentages. Note: the negative scale may be different from the positive scale in order to compensate for the ratio distribution.  
"comp":颜色表示的vSize变量的vColor变量的百分比变化。注:负的规模从积极的规模可能是不同的,以便补偿的比例分配。

"dens":colors indicate density. This is aanalogous to a population density map where vSize-values are area sizes, vColor-values are populations per area, and colors are computed as densities (i.e.\ population per squared km's).  
"dens":颜色表示密度。这是vSize值的区域大小,人口密度图aanalogous的vColor值是每单位面积的人口和颜色计算密度(即\人口数的平方公里)。

"linked":each object has a distinct color, which can be useful for small multiples (objects are linked by color)  
"linked":每个对象都有一个不同的颜色,这是很有用的小倍数(对象链接的颜色)

"index":each aggregation level (defined by index) has a distinct color  
"index":每个聚合的层次(定义的index)有不同的颜色

"categorical":vColor is a categorical variable that determines the color   
"categorical":vColor是一个分类变量确定颜色


参数:title
title of the treemap. For small multiples, a vector of titles should be given. Titles are used to describe the sizes of the rectangles.
标题的树状图。对于小倍数,一个向量的标题应该放在首位。标题被用作描述的矩形的大小。


参数:subtitle
subtitle of the treemap. For small multiples, a vector of subtitles should be given. Subtitles are used to describe the colors of the rectangles.
字幕的树状图。对于小的倍数,字幕的向量应给予。字幕是用来描述的矩形的颜色。


参数:algorithm
name of the used algorithm: "squarified" or "pivotSize". The squarified treemap algorithm (Bruls et al., 2000) produces good aspect ratios, but ignores the sorting order of the rectangles (sortID). The ordered treemap, pivot-by-size, algorithm (Bederson et al., 2002) takes the sorting order (sortID) into account while aspect ratios are still acceptable.
使用的算法:"squarified"或"pivotSize"的名称。树形算法的squarified(Bruls等人,2000),产生良好的高宽比,但忽略的矩形的排列顺序(sortID)的。订购的树状图算法(Bederson等人,2002),转动大小,排列顺序(sortID)时考虑的长宽比还是可以接受的。


参数:sortID
name of the variable that determines the order in which the rectangles are placed from top left to bottom right. Also the values "size" and "color" can be used. To inverse the sorting order, use "-" in the prefix. By default, large rectangles are placed top left. For small multiples, a vector of variable names (one for each treemap) can be given. Only applicable when algortihm=="pivotSize".
名称的变量,决定该矩形被放置从顶部从左上到右下的顺序。还可以使用的值的“尺寸”和“颜色”。逆排序次序,用“ - ”前缀。默认情况下,大的矩形放在左上角。对于小的倍数,一个向量的变量名(其中一个为每个树形图)可以给出。只适用于algortihm=="pivotSize"。


参数:palette
either a color palette or a name of a Brewer palette (see display.brewer.all()). A Brewer palette can be reversed by prefixing its name with a "-".
一个调色板或名称的布鲁尔调色板(见display.brewer.all()“)。一个布鲁尔调色板是可以逆转的,它的名字的前缀以“ - ”。


参数:range
range of values that determine the colors. When omitted, the range of actual values is used. This range is mapped to palette.
确定的颜色的值的范围内。如果省略,则范围使用的实际值。这个范围被映射到palette。


参数:vColorRange
deprecated, use range instead.
不推荐使用,使用range“。


参数:fontsize.title
(maximum) font size of the title
(最大值)的标题的字体大小


参数:fontsize.labels
font size(s) of the data labels, which can be:   
字体大小(s)的数据标签,它可以是:

one number, which specifies the font size for all aggregation levels  
一个数字,它指定的字体大小,所有的聚合级别

vector of two numbers, which specific the font sizes for 1) the highest and 2) the other aggregation levels  
两个数的向量,该特定的字体大小为1)的最高和2)的其他聚合水平

vector of three numbers, which specific the font sizes for 1) the highest, 2) any in-between, and 3) the lowest aggregation level. </ul>
矢量的三个数字中,特定的字体大小为1)最高,2)中的任何一个之间的,和3)的最低聚合水平。 </ ul>


参数:fontsize.legend
(maximum) font size of the legend
字体大小(最大)的传说


参数:lowerbound.cex.labels
multiplier between 0 and 1 that sets the lowerbound for the data label font sizes: 0 means draw all data labels, and 1 means only draw data labels if they fit at fontsize.data.
设置数据标签的字体大小:0表示绘制的所有数据标签,而1表示只提取数据的标签,他们是否适合在fontsize.data下界乘数介于0和1之间。


参数:inflate.labels
logical that determines whether data labels are inflated inside the rectangles.
逻辑决定矩形内的数据标签是否被夸大。


参数:bg.labels
background color of labels of high aggregation levels. If set to NA, the color is determined by the color of the underlying rectangle. For value, categorical and linked treemaps, the default is transparent grey ("#CCCCCCAA"), and for the other types, NA.
背景颜色的聚集水平高的标签。如果设置为NA,颜色确定由底层的矩形的颜色。值,分类和链接树图,默认情况下是透明的灰色("#CCCCCCAA"),以及其他类型,NA。


参数:force.print.labels
logical that determines whether data labels are being forced to be printed (also when they don't fit).
逻辑决定是否被迫要打印的数据标签时,他们不适合。


参数:position.legend
position of the legend: "bottom", "right", or "none". For categorical and index treemaps, "right" is the default value, for linked treemap, "none", and for the other types, "bottom".
位置的传说:"bottom","right"或"none"。对于分类和索引树图,"right"是默认值,为链接的树状图,"none",并为其他类型,"bottom"。


参数:aspRatio
preferred aspect ratio of the main rectangle, defined by width/height. When set to NA, the available window size is used.
主矩形,优选的纵横比定义的宽度/高度。当设置为NA,可用的窗口大小被使用。


参数:na.rm
logical that determines whether missing values are omitted during aggregation
逻辑决定是否遗漏值的聚集过程中被忽略


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

A list is silently returned:
默默返回一个列表:


参数:tm
list with for each treemap a data.frame containing information about the rectangles  <tr valign="top"><td>nRow</td>
列表与每一个树状图data.frame包含信息的矩形<tr valign="top"> <TD>nRow</ TD>

number of rows in the treemap grid  <tr valign="top"><td>nCol</td>
在树状图格的行数<tr valign="top"> <TD> nCol</ TD>

number of rows in the treemap grid
在树状图格的行数


参数:vSize
argument vSize  <tr valign="top"><td>vColor</td>
参数VSIZE <tr valign="top"> <TD> vColor</ TD>

argument vColor </table>
参数vColor </ TABLE>

This list can be used to locate a mouse click (see tmLocate).
这个列表可以用来定位用鼠标点击(见tmLocate“)。


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

Ordered and Quantum Treemaps: Making Effective Use of 2D Space to Display Hierarchies. ACM Transactions on Graphics, 21(4): 833-854.
Treemaps. In: W. de Leeuw, R. van Liere (eds.), Data Visualization 2000, Proceedings of the joint Eurographics and IEEE TCVG Symposium on Visualization, 2000, Springer, Vienna, p. 33-42.

实例----------Examples----------


#########################################[########################################]
### quick example[简单的例子##]
###[##]
### data: Gross national income data[##数据:国民总收入数据]
#########################################[########################################]

# load Gross national income data[加载国民总收入数据]
data(GNI2010)

# create treemap[创建树状图]
tmPlot(GNI2010,
       index=c("continent", "iso3"),
       vSize="population",
       vColor="GNI",
       type="value")



#########################################[########################################]
### extended examples[##扩展的例子]
###[##]
### data: fictive structural business statistics data[##数据:虚构的结构性企业统计数据]
#########################################[########################################]

### load fictive structural business statistics data[##加载虚构的结构性企业统计数据]
data(sbsData)
sbsData$employees.growth <- sbsData$employees09 - sbsData$employees08


#########################################[########################################]
### types[##类型]
#########################################[########################################]

# value treemap: the color variable is directly mapped to the colors[值树状图:颜色可变的颜色直接映射到]
tmPlot(sbsData,
       index=c("section", "subsection"),
       vSize="employees09",
       vColor="employees.growth",
       type="value")

# comparisson treemaps: colors indicate change of vSize with respect to vColor[comparisson树图的颜色表示,VSIZE就到vColor的变化]
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           vColor="employees08",
           type="comp")

# four comparisson treemaps[四comparisson树图]
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize=c("employees09", "value added09", "turnover09", "salaries09"),
           vColor=c("employees08", "value added08", "turnover08", "salaries08"),
           type="comp")

# density treemaps: colors indicate density (like a population density map)[密度树图的颜色表示密度(如人口密度图)]
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="turnover09",
           vColor="employees09*1000",
           type="dens")

tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           vColor="turnover09",
           type="dens")

# linked treemaps: objects are linked by color over different treemaps[挂树图:对象是联系在一起的颜色在不同的树图]
tmPlot(sbsData[sbsData$section=="Manufacturing",],
           index="subsection",
           vSize=c("income09", "employees09", "expenditures09", "salaries09"),
           type="linked")

# index treemap: each aggregation index has distinct color[指数树状图:每个聚集指数具有不同的颜色]
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           type="index")

# categorical treemap: colors are determined by a categorical variable[分类树状图:颜色是由分类变量]
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           vColor="section",
           type="categorical")

#########################################[########################################]
### layout algorithm[##布局算法]
#########################################[########################################]

tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           vColor="employees.growth",
           type="value",
           algorithm="squarified")

#########################################[########################################]
### graphical options: fontsize[##图形选项:字体大小]
#########################################[########################################]

# draw labels at fixed fontsize (fit only)[绘制标签(只适合在固定的字体大小)]
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           vColor="employees08",
           type="comp",
           fontsize.labels=12,
           lowerbound.cex.labels=1)

# draw labels at flexible fontsize (skip tiny rectangles)[绘制标签,灵活的字体大小(跳过微小的矩形)]
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           vColor="employees08",
           type="comp",
           fontsize.labels=12,
           lowerbound.cex.labels=.6)

# draw labels at maximal fontsize[最大的字体大小绘制标签]
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           vColor="employees08",
           type="comp",
           fontsize.labels=10,
           lowerbound.cex.labels=1,
           inflate.labels = TRUE)

# draw all labels at fixed fontsize[吸引所有的标签在固定的字体大小]
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           vColor="employees08",
           type="comp",
           fontsize.labels=10,
           lowerbound.cex.labels=1,
           force.print.labels=TRUE)

#########################################[########################################]
### graphical options: color palette[##图形选项:调色板]
#########################################[########################################]

# terrain colors[地形的颜色]
sbsData$employees.growth <- sbsData$employees09 - sbsData$employees08
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           vColor="employees.growth",
           type="value",
           palette=terrain.colors(10))

# Brewer's Red-White-Grey palette reversed with predefined range[布鲁尔的红,白,灰色的调色板逆转预定义的范围]
tmPlot(sbsData,
           index=c("section", "subsection"),
           vSize="employees09",
           vColor="employees.growth",
           type="value",
           palette="-RdGy",
           range=c(-20000,20000))

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-29 22:40 , Processed in 0.020457 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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