我有以下代码:
library(GGally)
library(nycflights13)
library(tidyverse)
dat <- nycflights13::flights %>%
select(dep_time, sched_dep_time, dep_delay, arr_time, sched_arr_time, arr_delay) %>%
sample_frac(0.01)
dat
ggpairs(dat)
Run Code Online (Sandbox Code Playgroud)
它产生了这个:
如何添加密度着色,使其如下所示:
我看到这些帖子 GGally :: ggpairs绘图没有网格线时绘制相关系数 使用ggpairs来创建这个图
阅读后,我能够实现这个黑客https://github.com/tonytonov/ggally/blob/master/R/gg-plots.r,我的情节看起来像这样
我认为这是一个很好的结果,但我无法改变颜色.
MWE就是这个
library(ggally)
# load the hack
source("ggally_mod.R")
# I saved https://github.com/tonytonov/ggally/blob/master/R/gg-plots.r as "ggally_mod.R"
assignInNamespace("ggally_cor", ggally_cor, "GGally")
ggpairs(swiss)
Run Code Online (Sandbox Code Playgroud)
现在我想跑
ggpairs(swiss,
lower=list(continuous="smooth", wrap=c(colour="blue")),
diag=list(continuous="bar", wrap=c(colour="blue")))
Run Code Online (Sandbox Code Playgroud)
但颜色保持不变.有没有办法改变颜色,因为params不再工作了?