【发布时间】:2021-09-26 03:31:28
【问题描述】:
随着数据点数量的增加,样条线在背景下变得不可见。 如何使样条线的颜色变暗? 或者另一种解决此可见性问题的方法?
library(dplyr)
library(ggplot2)
library(mgcv)
# Summer
Summer <- mgcv::gamSim(eg=5,n=10000,dist="normal",scale=0.6,verbose=TRUE) %>%
mutate(x = x2 * 20) %>%
rename("Season" = x0) %>%
mutate(Season = ifelse(Season == "1", "Summer", Season)) %>%
filter(.,Season == "Summer") %>%
select(y, x, Season)
# Winter
Winter <- mgcv::gamSim(eg=5,n=10000,dist="normal",scale=1.0,verbose=TRUE) %>%
mutate(x = x1 * 20) %>%
rename("Season" = x0) %>%
mutate(Season = ifelse(Season == "3", "Winter", Season)) %>%
filter(.,Season == "Winter") %>%
select(y, x, Season)
# Bind
DF <- rbind(Summer, Winter)
# Plot
Plot <- DF %>%
ggplot(., aes(x = x, y = y, colour = Season)) +
geom_jitter() +
geom_point(shape=21, alpha = 0.5, size=0.05) +
geom_smooth(method = "gam", formula = y ~ s(x, bs = "cs", k = 10), lwd = 1.6)
Plot
【问题讨论】: