7

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.

Ana
  • 83
  • 1
  • 1
  • 4

1 Answers1

19

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

enter image description here

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • See also [this answer](https://stackoverflow.com/a/46964952/2052738) if you want to change those default colours with a manual scale (`wrap` won't accept `manual_colour_scale`). – FairMiles Oct 26 '17 at 22:48