我有以下数据:
structure(list(RR = c(0.89, 0.9, 0.92, 0.93, 0.94, 0.95, 0.96,
0.98, 0.99, 1, 1.01, 1.03, 1.04, 1.05, 1.06, 1.08, 1.09, 1.11,
1.12, 1.13, 1.15), CI.upper = c(1, 1, 1.01, 1.01, 1.01, 1.01,
1.02, 1.03, 1.04, 1.05, 1.06, 1.08, 1.1, 1.12, 1.13, 1.16, 1.18,
1.21, 1.23, 1.25, 1.29), CI.lower = c(0.78, 0.8, 0.83, 0.85,
0.87, 0.89, 0.9, 0.93, 0.94, 0.95, 0.96, 0.98, 0.98, 0.98, 0.99,
1, 1, 1.01, 1.01, 1.01, 1.01), quan_demands = c(0, 5, 10, 15,
20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95,
100)), class = "data.frame", row.names = c(NA, -21L))
我正在绘制 RR 及其各自的置信区间,但我似乎无法找到一种方法来使穿过点的线和置信区间更平滑。
我曾尝试使用 geom_smooth 和 stat_smooth 但没有成功。
我的代码是这个:
ggplot(data = data, aes(x= quan_demands, y = RR)) +
geom_point(size = 1, shape = 19, color = "darkblue") +
geom_line(size = 0.5, colour = "darkblue") +
geom_ribbon(aes(ymin = CI.lower, ymax = CI.upper), linetype = 2, alpha = 0.4, fill =
"deepskyblue3") +
theme_bw() +
scale_x_continuous(limits = c(0, 100),
breaks = seq(0, 100, 25)) +
scale_y_continuous(limits = c(0.75, 1.4),
breaks = seq(0, 1.5, 0.2)) +
geom_vline(xintercept = 45, color = "black", linetype = "dashed") +
geom_hline(yintercept = 1, color = "black", linetype = "dashed") +
theme(plot.background = element_rect(fill = "white"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_rect(color = "black", size = 1),
axis.ticks = element_line(color = "black", size = 1),
axis.text = element_text(color = "black", size = 12),
plot.margin = unit(c(1, 1, 1, 1), "mm"),
strip.background = element_rect(fill = "deepskyblue3", size = 1),
strip.text.x = element_text(colour = "white", size = 13)) +
facet_grid(. ~ "title")
有什么帮助吗? :)