在ggplot2中创建散点图的矩阵(对()等价) [英] Create a matrix of scatterplots (pairs() equivalent) in ggplot2
问题描述
是否可以使用 ggplot
的很好的特性(如映射)绘制散点图矩阵,其中 ggplot2
额外的因素来颜色,形状等,并添加更平滑?
我正在考虑类似于 base
函数 pairs
。
您可能想试试plotmatrix:
library(ggplot2)
data(mtcars)
plotmatrix(mtcars [,1:3])
对我来说mpg(mtcars中的第一列)不应该是一个因素。我没有检查过它,但没有理由为什么它应该是一个。但是我得到一个散点图:)
注意:为了将来参考, plotmatrix()
函数已被 GGally $ c>中的
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屋!