pair correlation ggpair ggmatrix
https://zhuanlan.zhihu.com/p/23400450

R 语言矩阵散点图
EasyCharts· 15 天前散点图矩阵因包含多种多副图片,因此含有更多的信息,特别是不同变量之间相关关系。本文介绍了四种绘制散点图矩阵的函数。graphics(pairs),car( spm),GGally(ggscatmat), GGally(ggpairs)四种。
① graphics 包 pairs 函数
data(trees)
panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y))
txt <- format(c(r, 0.123456789), digits = digits)[1]
txt <- paste0(prefix, txt)
if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex.cor * r)
}
panel.hist <- function(x, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(usr[1:2], 0, 1.5) )
h <- hist(x, plot = FALSE)
breaks <- h$breaks; nB <- length(breaks)
y <- h$counts; y <- y/max(y)
rect(breaks[-nB], 0, breaks[-1], y, col = "cyan", ...)
}
pairs(trees,
labels = c('树周长','树高','树体积'),
lower.panel=panel.cor,
upper.panel=panel.smooth,
diag.panel=panel.hist,
main = 'The Scatterplot Matrix of The Trees Data',
pch = 21,
bg = "orange",
line.main=1.5,
oma=c(2,2,3,2)
)

② car 包 spm 函数
#diagonal=c("density", "boxplot", "histogram", "oned", "qqplot", "none")
library(car)
data("trees")
spm(trees,
diagonal='histogram',
main='The Scatterplot Matrix of The Trees Data')

③GGally 包 ggscatmat 函数
library(GGally)
#ggscatmat(trees)
data("iris")
ggscatmat(iris, columns = 1:4,color = 'Species' )

④ GGally 包 ggpairs函数
library(ggplot2)
library(GGally)
data(tips,package="reshape")
#pairs(tips[,1:3])
pm1 <- ggpairs(
tips[,c(1,3,4,2)],
mapping = ggplot2::aes(color = sex,shape=sex,alpha = 0.4),
upper = list(continuous = "cor", combo = "box", discrete = "facetbar"),
lower = list(continuous = "points", combo = "facethist", discrete = "facetbar"),
diag = list(continuous = "densityDiag", discrete = "barDiag")
)
pm1

data(iris)
pm2 <- ggpairs(
iris[,c(1,2,5,3,4)],
mapping = ggplot2::aes(color = Species,shape=Species,alpha = 0.4),
upper = list(continuous = "density", combo = "box"),
lower = list(continuous = "points", combo = "dot"),
title = "Iris",
axisLabels ="internal")
pm2

data(diamonds, package="ggplot2")
diamonds.samp <- diamonds[sample(1:dim(diamonds)[1], 200), ]
# Custom Example
pm3 <- ggpairs(
diamonds.samp[, 1:5],
mapping = ggplot2::aes(color = cut),
upper = list(continuous = wrap("density", alpha = 0.5), combo = "box"),
lower = list(continuous = wrap("smooth", alpha = 0.3), combo = wrap("dot", alpha = 0.4)),
title = "Diamonds"
)
pm3

EasyCharts团队出品
帅的人都关注了EasyCharts团队^..^~
QQ交流群:454614789
微信公众号:EasyCharts
pair correlation ggpair ggmatrix的更多相关文章
- [文学阅读] METEOR: An Automatic Metric for MT Evaluation with Improved Correlation with Human Judgments
METEOR: An Automatic Metric for MT Evaluation with Improved Correlation with Human Judgments Satanje ...
- KCF:High-Speed Tracking with Kernelized Correlation Filters 的翻译与分析(一)。分享与转发请注明出处-作者:行于此路
High-Speed Tracking with Kernelized Correlation Filters 的翻译与分析 基于核相关滤波器的高速目标跟踪方法,简称KCF 写在前面,之所以对这篇文章 ...
- 相关系数(CORRELATION COEFFICIENTS)会骗人?
CORRELATION COEFFICIENTS We've discussed how to summarize a single variable. The next question is ho ...
- Correlation and Regression
Correlation and Regression Sample Covariance The covariance between two random variables is a statis ...
- [Statistics] Comparison of Three Correlation Coefficient: Pearson, Kendall, Spearman
There are three popular metrics to measure the correlation between two random variables: Pearson's c ...
- c++ pair 使用
1. 包含头文件: #include <utility> 2. pair 的操作: pair<T1,T2> p; pair<T1,T2> p(v1,v2); pai ...
- 论Pair的重要性
这些天我在用React和D3做图表,从已经实现的图表里复制了一些坐标轴的代码,发现坐标轴上的n个点里,只有第一个点下面能渲染出文字提示,其余点下面都无法渲染出文字. 和组里的FL一起百思不得其解好几天 ...
- 2016 ACM/ICPC Asia Regional Dalian Online 1010 Weak Pair dfs序+分块
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submissio ...
- pair的使用
#include<iostream> #include<cmath> #include<cstdio> #include<algorithm> #inc ...
随机推荐
- MS SQL 需要定期清理日志文件
前言碎语 关于对SQL SERVER 日志文件管理方面了解不多的话,可以参考我的这篇博客文章“MS SQL 日志记录管理”,不过这篇文章只是介绍对SQL SERVER日志记录的深入认知了解,并没有提出 ...
- imcs初探
imcs简介 https://github.com/knizhnik/imcs 翻译过来是在内存上的列存储,在对于一张'静态'的表计算方面很有优势,在许多聚合运算中都有使用线程并行计算,而且其中使用了 ...
- java服务器端编程
由于要做手机端安卓程序,所以使用java来开发.后来又看了javaweb,觉得java还是很不错的,功能很强大,可以做很多事,最重要的是资源非常丰富,有很多开源的库框架之类. 最近用java做一个服务 ...
- js输出二维数组最长的子数组
,,],[,,,],[,,,,]]; ].length; ; i < a.length; i++) { if (max<a[i].length) { max=a[i].length; va ...
- TFS修改项目名称
引言 如何让TFS管理的项目更名后不丢失修改历史记录? 在工作中有时由于前期考虑不足,某个Project的名字在项目开发过程中需要修改以更准备表达它的功能.本文就对此进行抛砖引玉 操作 在Source ...
- WinCE常用调试工具汇总
WinCE驱动调试助手V2.9 http://www.cnblogs.com/we-hjb/archive/2009/05/17/1458725.html WinCE串口调试助手V2.1 http:/ ...
- oracle 密码有效期
oracle的密码是存在有效期的,有时候会遇到密码到期需要重设的情况,查看当前密码有效期的语句: SELECT * FROM dba_profiles s WHERE s.profile='DEFAU ...
- CH Round #30 摆花[矩阵乘法]
摆花 CH Round #30 - 清明欢乐赛 背景及描述 艺术馆门前将摆出许多花,一共有n个位置排成一排,每个位置可以摆花也可以不摆花.有些花如果摆在相邻的位置(隔着一个空的位置不算相邻),就不好看 ...
- Winform listview控件、 容器控件
1.常用的基本属性: (1)FullRowSelect:设置是否行选择模式.(默认为false) 提示:只有在Details视图该属性才有意义. (2) GridLines:设置行和列之间是否显示网格 ...
- Confluence Wiki -- 页面限制
Confluence Wiki 中 [页面设置] 应该如何理解? 当一个用户有这个权限后,这个用户可以对一个页面做限制,可以限制这个页面不能被其他用户浏览或编辑: 反之,如果没有这个权限,那么这个用户 ...
