Coloring points based on variable with R ggpairs

I'm trying to reproduce the figure in https://tgmstat.wordpress.com/2013/11/13/plot-matrix-with-the-r-package-ggally/ with the code

require(GGally)
data(tips, package="reshape")
ggpairs(data=tips, title="tips data", colour = "sex") 

However, in the plot I get the points are not colored based on sex, instead they are all the same color. I get the following warning

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.

I've tried adding ggplot2::aes(colour = sex), but that did not work either.

Does anyone else here have the same problem? I'm using R version 3.3.1 and GGally_1.2.0.

Thanks.


GGally has been under fairly rapid development, so it's not surprising that a blog post from 2013 has out-of-date code. When I run your code with GGally 1.2.0 I get the same warning. It works for me if I add the mapping:

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

Following the wiki page for the wrap() incantation to stop complaints about needing to set binwidth in stat_bin ...

在这里输入图像描述

链接地址: http://www.djcxy.com/p/30920.html

上一篇: ggpairs的自定义组平均函数

下一篇: 基于R ggpairs变量的着色点