下图

使用以下代码生成:
library(GGally)
dat <- read.csv("http://www.ats.ucla.edu/stat/data/tobit.csv")
ggpairs(dat[, c("read", "math", "apt")])如何为上面的每个散点图添加相关线?
发布于 2015-06-16 07:40:42
像这样的东西?
ggpairs(dat[, c("read", "math", "apt")],lower = list(continuous = "smooth", params = c(method = "loess", fill = "blue"))

发布于 2021-04-05 21:29:56
您可以在如下所示的函数中自定义下三角形中的散点图:
library(GGally)
dat <- ggplot2::diamonds[1:1000, c("x", "y", "z")] # Example data
# Customize your scatterplots as you wish here:
lowerfun <- function(data, mapping) {
ggplot(data = data, mapping = mapping)+
geom_point(alpha = .25) +
geom_smooth(method = "loess", formula = y ~ x,
fill = "blue", color = "red", size = 0.5)
}
# Plot the scatterplot matrix
ggpairs(dat, lower = list(continuous = wrap(lowerfun)))

https://stackoverflow.com/questions/30856602
复制相似问题