【问题标题】:How can I add colours in ggpairs (GGally)?如何在 ggpairs (GGally) 中添加颜色?
【发布时间】:2021-12-23 17:58:39
【问题描述】:

我是 GGally 的新手,我想问你如何在 ggpairs() 中的变量的不同行中添加颜色。我可以给每个颜色一个特定的颜色吗?

谢谢!

【问题讨论】:

    标签: colors ggally


    【解决方案1】:

    如果您只想为组添加/指定颜色,您可以使用 scale_fill_manual 或 scale_color_manual 手动设置这些,具体取决于绘图的上/下/对角区域中的绘图类型:

    library(GGally)
    pm <- ggpairs(flea, columns = 2:4, ggplot2::aes(colour=species))
    
    pm +
     scale_color_manual(values = c("red", "blue", "purple")) +
     scale_fill_manual(values = c("red", "blue", "purple"))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-31
      • 2015-04-10
      • 1970-01-01
      • 2015-05-06
      • 2014-05-05
      • 2016-05-07
      • 2021-12-15
      • 1970-01-01
      相关资源
      最近更新 更多