Coloring points based on variable with R ggpairs

14,651

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

Share:
14,651
Admin
Author by

Admin

Updated on June 24, 2022

Comments

  • Admin
    Admin almost 2 years

    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.

  • FairMiles
    FairMiles over 6 years
    See also this answer if you want to change those default colours with a manual scale (wrap won't accept manual_colour_scale).