R package:corrplot相关系数矩阵可视化

Description

说明

A graphical display of a correlation matrix, confidence interval. The details are paid great attention to. It can also visualize a general matrix by setting is.corr = FALSE.
相关系数矩阵,置信区间的可视化展示。重视大量细节。它还可以通过设置is.corr=FALSE可视化一般矩阵。

使用方法

Usage

corrplot(corr, method = c("circle", "square", "ellipse", "number", "shade",
"color", "pie"), type = c("full", "lower", "upper"), add = FALSE,
col = NULL, bg = "white", title = "", is.corr = TRUE, diag = TRUE,
outline = FALSE, mar = c(0, 0, 0, 0), addgrid.col = NULL,
addCoef.col = NULL, addCoefasPercent = FALSE, order = c("original",
"AOE", "FPC", "hclust", "alphabet"), hclust.method = c("complete", "ward",
"ward.D", "ward.D2", "single", "average", "mcquitty", "median", "centroid"),
addrect = NULL, rect.col = "black", rect.lwd = 2, tl.pos = NULL,
tl.cex = 1, tl.col = "red", tl.offset = 0.4, tl.srt = 90,
cl.pos = NULL, cl.lim = NULL, cl.length = NULL, cl.cex = 0.8,
cl.ratio = 0.15, cl.align.text = "c", cl.offset = 0.5, number.cex = 1,
number.font = 2, number.digits = NULL, addshade = c("negative",
"positive", "all"), shade.lwd = 1, shade.col = "white", p.mat = NULL,
sig.level = 0.05, insig = c("pch", "p-value", "blank", "n", "label_sig"),
pch = 4, pch.col = "black", pch.cex = 3, plotCI = c("n", "square",
"circle", "rect"), lowCI.mat = NULL, uppCI.mat = NULL, na.label = "?",
na.label.col = "black", win.asp = 1, ...)

Arguments

参数

corr

The correlation matrix to visualize, must be square if order is not "original". For general matrix, please using is.corr = FALSE to convert.
要可视化的相关系数矩阵,如果顺序不是“原始”的,则必须是正方。对于一般矩阵,请使用is.corr=FALSE转换。

method

Character, the visualization method of correlation matrix to be used. Currently, it supports seven methods, named "circle" (default), "square", "ellipse", "number", "pie", "shade" and "color". See examples for details.
字符串,采用相关系数矩阵的可视化方法。目前,它支持七种方法,分别为“circle”(默认)、“square”、“ellipse”、“number”、“pie”、“shade”和“color”。有关详细信息,请参见示例。
The areas of circles or squares show the absolute value of corresponding correlation coefficients. Method "pie" and "shade" came from Michael Friendly's job (with some adjustment about the shade added on), and "ellipse" came from D.J. Murdoch and E.D. Chow's job, see in section References.
圆或正方形的面积表示相应相关系数的绝对值。方法“pie”和“shade”来自Michael Friendly的工作(添加了一些关于shade的调整),而“elliple”来自D.J.Murdoch和E.D.Chow的工作,参见参考资料一节。

type

Character, "full" (default), "upper" or "lower", display full matrix, lower triangular or upper triangular matrix.
字符串,“full”(默认)、“upper”或“lower”,分别显示完整矩阵、下三角矩阵或上三角矩阵。

add

Logical, if TRUE, the graph is added to an existing plot, otherwise a new plot is created.
逻辑值,如果为TRUE,则将该图添加到现有的图表中,否则创建新的图表。

col

Vector, the color of glyphs. It is distributed uniformly in cl.lim. If NULL, col will be colorRampPalette(col2)(200), see example about col2.
向量,字形的颜色。在cl.lim中均匀分布。如果为空,则col将为colorRampPalette(col2)(200),参见关于col2的示例

bg

The background color.
背景颜色

title

Character, title of the graph.
字符串

is.corr

Logical, whether the input matrix is a correlation matrix or not. We can visualize the non-correlation matrix by setting is.corr = FALSE.

diag

Logical, whether display the correlation coefficients on the principal diagonal.

outline

Logical or character, whether plot outline of circles, square and ellipse, or the color of these glyphs. For pie, this represents the color of the circle outlining the pie. If outline is TRUE, the default value is "black".

mar

See par.

addgrid.col

The color of the grid. If NA, don't add grid. If NULL the default value is chosen. The default value depends on method, if method is color or shade, the color of the grid is NA, that is, not draw grid; otherwise "grey".

addCoef.col

Color of coefficients added on the graph. If NULL (default), add no coefficients.

addCoefasPercent

Logic, whether translate coefficients into percentage style for spacesaving.

order

Character, the ordering method of the correlation matrix.
字符串
"original" for original order (default).
“original”表示原始顺序(默认)。
"AOE" for the angular order of the eigenvectors.
"AOE"表示特征向量的角阶。
"FPC" for the first principal component order.
“FPC”表示第一主成分阶。
"hclust" for the hierarchical clustering order.
“hclust”表示层次聚类顺序。
"alphabet" for alphabetical order.
"alphabet" 表示按“字母表”顺序排列。
See function corrMatOrder for details.
详情请参阅函数corrMatOrder

hclust.method

Character, the agglomeration method to be used when order is hclust. This should be one of "ward", "ward.D", "ward.D2", "single", "complete", "average", "mcquitty", "median" or "centroid".

addrect

Integer, the number of rectangles draws on the graph according to the hierarchical cluster, only valid when order is hclust. If NULL (default), then add no rectangles.

rect.col

Color for rectangle border(s), only valid when addrect is equal or greater than 1.

rect.lwd

Numeric, line width for borders for rectangle border(s), only valid when addrect is equal or greater than 1.

tl.pos

Character or logical, position of text labels. If character, it must be one of "lt", "ld", "td", "d" or "n". "lt"(default if type=="full") means left and top, "ld"(default if type=="lower") means left and diagonal, "td"(default if type=="upper") means top and diagonal(near), "d" means diagonal, "n" means don't add textlabel.
字符串或逻辑值,label的位置。如果是字符串,是"lt", "ld", "td", "d" or "n"其中之一。

tl.cex

Numeric, for the size of text label (variable names).
数值型, label的字体大小

tl.col

The color of text label.
label的颜色

tl.offset
Numeric, for text label, see text.

tl.srt
Numeric, for text label string rotation in degrees, see text.

cl.pos
Character or logical, position of color labels; If character, it must be one of "r" (default if type=="upper" or "full"), "b" (default if type=="lower") or "n", "n" means don't draw colorlabel.

cl.lim
The limits (x1, x2) in the colorlabel.

cl.length

Integer, the number of number-text in colorlabel, passed to colorlegend. If NULL, cl.length is length(col) + 1 when length(col) <=20; cl.length is 11 when length(col) > 20
整数,传递给colorlegend的colorlabel中的数字文本数。如果为空,中心线长度长度(col)<=20时为长度(col)+1;中心线长度长度(col)>20时为11
cl.cex
Numeric, cex of number-label in colorlabel, passed to colorlegend.

cl.ratio

Numeric, to justify the width of colorlabel, 0.1~0.2 is suggested.

cl.align.text

Character, "l", "c" (default) or "r", for number-label in colorlabel, "l" means left, "c" means center, and "r" means right.

cl.offset
Numeric, for number-label in colorlabel, see text.

number.cex

The cex parameter to send to the call to text when writing the correlation coefficients into the plot.

number.font

the font parameter to send to the call to text when writing the correlation coefficients into the plot.

number.digits

indicating the number of decimal digits to be added into the plot. Non-negative integer or NULL, default NULL.

addshade

Character for shade style, "negative", "positive" or "all", only valid when method is "shade". If "all", all correlation coefficients' glyph will be shaded; if "positive", only the positive will be shaded; if "negative", only the negative will be shaded. Note: the angle of shade line is different, 45 degrees for positive and 135 degrees for negative.

shade.lwd

Numeric, the line width of shade.

shade.col

The color of shade line.

p.mat

Matrix of p-value, if NULL, arguments sig.level, insig, pch, pch.col, pch.cex is invalid.

sig.level

Significant level, if the p-value in p-mat is bigger than sig.level, then the corresponding correlation coefficient is regarded as insignificant. If insig is "label_sig", this may be an increasing vector of significance levels, in which case pch will be used once for the highest p-value interval and multiple times (e.g. "", "", "**") for each lower p-value interval.

insig

Character, specialized insignificant correlation coefficients, "pch" (default), "p-value", "blank", "n", or "label_sig". If "blank", wipe away the corresponding glyphs; if "p-value", add p-values the corresponding glyphs; if "pch", add characters (see pch for details) on corresponding glyphs; if "n", don't take any measures; if "label_sig", mark significant correlations with pch (see sig.level).

pch

Add character on the glyphs of insignificant correlation coefficients(only valid when insig is "pch"). See par.

pch.col

The color of pch (only valid when insig is "pch").

pch.cex

The cex of pch (only valid when insig is "pch").

plotCI

Character, method of ploting confidence interval. If "n", don't plot confidence interval. If "rect", plot rectangles whose upper side means upper bound and lower side means lower bound, respectively, and meanwhile correlation coefficients are also added on the rectangles. If "circle", first plot a circle with the bigger absolute bound, and then plot the smaller. Warning: if the two bounds are the same sign, the smaller circle will be wiped away, thus forming a ring. Method "square" is similar to "circle".

lowCI.mat

Matrix of the lower bound of confidence interval.

uppCI.mat

Matrix of the upper bound of confidence interval.

na.label

Label to be used for rendering NA cells. Default is "?". If "square", then the cell is rendered as a square with the na.label.col color.

na.label.col

Color used for rendering NA cells. Default is "black".

win.asp

Aspect ration for the whole plot. Value other than 1 is currently compatible only with methods "circle" and "square".

...

Additional arguments passing to function text for drawing text lable.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
禁止转载,如需转载请通过简信或评论联系作者。
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,271评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,275评论 2 380
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,151评论 0 336
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,550评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,553评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,559评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,924评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,580评论 0 257
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,826评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,578评论 2 320
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,661评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,363评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,940评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,926评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,156评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,872评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,391评论 2 342