简体   繁体   English

基于R ggpairs变量的着色点

[英]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 我正在尝试使用代码重现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") 

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. 警告消息:在warn_if_args_exist(list(...))中:额外的参数:'color'被忽略。 If these are meant to be >aesthetics, submit them using the 'mapping' variable within ggpairs with >ggplot2::aes or ggplot2::aes_string. 如果这些是>美学,请使用ggpairs中的'mapping'变量提交它们> ggplot2 :: aes或ggplot2 :: aes_string。

I've tried adding ggplot2::aes(colour = sex), but that did not work either. 我试过添加ggplot2 :: aes(color = sex),但这也不起作用。

Does anyone else here have the same problem? 这里有没有其他人有同样的问题? I'm using R version 3.3.1 and GGally_1.2.0. 我正在使用R版本3.3.1和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. GGally开发速度相当快,因此2013年的博客文章中有过时的代码就不足为奇了。 When I run your code with GGally 1.2.0 I get the same warning. 当我用GGally 1.2.0运行你的代码时,我得到了相同的警告。 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 ... wrap()咒语的wiki页面之后停止关于需要在binwidth中设置binwidthstat_bin ...

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM