基于变量的着色点与 R ggpairs

Coloring points based on variable with R ggpairs

我正在尝试用代码

重现https://tgmstat.wordpress.com/2013/11/13/plot-matrix-with-the-r-package-ggally/中的图形
require(GGally)
data(tips, package="reshape")
ggpairs(data=tips, title="tips data", colour = "sex") 

然而,在我得到的情节中,点不是根据性别着色的,而是它们都是相同的颜色。我收到以下警告

Warning message: In warn_if_args_exist(list(...)) : Extra arguments: 'colour' are being ignored. If these are meant to be >aesthetics, submit them using the 'mapping' variable within ggpairs with >ggplot2::aes or ggplot2::aes_string.

我试过添加 ggplot2::aes(colour = sex),但也没用。

这里还有其他人遇到同样的问题吗?我正在使用 R 版本 3.3.1 和 GGally_1.2.0.

谢谢。

GGally 的发展速度相当快,所以 2013 年的博客 post 有过时的代码也就不足为奇了。当我 运行 你的代码使用 GGally 1.2.0 时,我得到了同样的警告。如果我添加映射,它对我有用:

require(GGally)
data(tips, package="reshape")
g1 <- ggpairs(data=tips, title="tips data",
  mapping=ggplot2::aes(colour = sex),
  lower=list(combo=wrap("facethist",binwidth=1)))

遵循 the wiki pagewrap() 咒语以停止关于需要在 stat_bin 中设置 binwidth 的抱怨 ...