绘制多变量数据

R 中的多元概率分布

Surajit Ray

Professor, University of Glasgow

多种作图方式

 

  • 基础 R 作图
  • lattice
  • ggplot
  • 3D 作图选项
R 中的多元概率分布

多变量的基础 R 作图

pairs(iris_raw[, 1:4])

成对图

  • 变量多时不太实用
R 中的多元概率分布

按颜色的成对图

pairs(iris_raw[, 1:4], col = iris_raw$Species)

按物种的成对图

R 中的多元概率分布

Lattice

library(lattice)
splom(~iris_raw[, 1:4], col = iris_raw$Species, pch = 16)

R 中的多元概率分布

使用 ggplot

library(ggplot2)
library(GGally)
ggpairs(data = iris_raw, columns = 1:4, mapping = aes(color = Species))

ggplot

R 中的多元概率分布

3D 图

library(scatterplot3d)
scatterplot3d(iris_raw[, c(1, 3, 4)], color = as.numeric(iris_raw$Species))

3D 图

R 中的多元概率分布

3D 图

scatterplot3d(iris_raw[, c(1, 3, 4)], color = as.numeric(iris_raw$Species),pch = 4, angle = 80)

3D 变化

R 中的多元概率分布

用葡萄酒数据练习绘图吧!

R 中的多元概率分布

Preparing Video For Download...