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

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

问题描述

是否可以使用 ggplot 的很好的特性(如映射)绘制散点图矩阵,其中 ggplot2 额外的因素来颜色,形状等,并添加更平滑?

我正在考虑类似于 base 函数 pairs

解决方案

您可能想试试plotmatrix:

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

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




注意:为了将来参考, plotmatrix()函数已被 GGally 中的 ggpairs()函数取代$ c> package as @ naught101建议在此问题的在下面的另一个回复中。


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?

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

解决方案

You might want to try plotmatrix:

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

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 :)


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中创建散点图的矩阵(对()等价)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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