在 ggplot2 中创建散点图矩阵(pairs() 等效) [英] Create a matrix of scatterplots (pairs() equivalent) in ggplot2

查看:26
本文介绍了在 ggplot2 中创建散点图矩阵(pairs() 等效)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 ggplot2 绘制散点图矩阵,使用 ggplot 的出色功能,例如将附加因素映射到颜色、形状等并添加平滑度?

Is it possible to plot a matrix of scatter plots with ggplot2, using ggplot's nice features like mapping additional factors to color, shape etc. and adding smoother?

我正在考虑类似于 base 函数 pairs 的东西.

I am thinking about something similar to the base function pairs.

推荐答案

您可能想尝试 plotmatrix:

You might want to try plotmatrix:

  library(ggplot2)
  data(mtcars)
  plotmatrix(mtcars[,1:3])

对我来说 mpg(mtcars 的第一列)不应该是一个因素.我没有检查过它,但没有理由为什么它应该是一个.但是我得到了一个散点图:)

to me mpg (first column in mtcars) should not be a factor. I haven't checked it, but there's no reason why it should be one. However I get a scatter plot :)

注意:为了将来参考,plotmatrix() 函数已替换为 GGally 中的 ggpairs() 函数 package as @naught101 建议在下面的另一个回复中对此问题.

Note: For future reference, the plotmatrix() function has been replaced by the ggpairs() function from the GGally package as @naught101 suggests in another response below to this question.

这篇关于在 ggplot2 中创建散点图矩阵(pairs() 等效)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆