ggplot() + geom_point(data = subset(df1, group == group1), aes(x = year, y = gdp, color = "#e64b35"), shape = 15, size = 1.2) + geom_smooth(data = subset(df1, group == group1), aes(x = year, y = gdp), color = "#e64b35", method = "lm", formula = y ~ x, linetype = "dashed", linewidth = 0.8) + stat_poly_eq(data = subset(df1, group == group1), aes(x = year, y = gdp + 5, label = paste(after_stat(eq.label), after_stat(rr.label), after_stat(p.value.label), sep = "*\", \"*")), formula = y ~ x, parse = TRUE, color = "#e64b35", geom = "text_repel", size = 3) + geom_point(data = subset(df1, group == group2), aes(x = year, y = gdp, color = "#00a087"), shape = 15, size = 1.2) + geom_smooth(data = subset(df1, group == group2), aes(x = year, y = gdp), color = "#00a087", method = "lm", formula = y ~ x, linetype = "dashed", linewidth = 0.8) + stat_poly_eq(data = subset(df1, group == group2), aes(x = year + 12, y = gdp + 3.5, label = paste(after_stat(eq.label), after_stat(rr.label), after_stat(p.value.label), sep = "*\", \"*")), formula = y ~ x, parse = TRUE, color = "#00a087", geom = "text_repel", size = 3, angle = 4) + geom_point(data = subset(df1, group == group3), aes(x = year, y = gdp, color = "#3c5488"), shape = 15, size = 1.2) + geom_smooth(data = subset(df1, group == group3), aes(x = year, y = gdp), color = "#3c5488", method = "lm", formula = y ~ x, linetype = "dashed", linewidth = 0.8) + stat_poly_eq(data = subset(df1, group == group3), aes(x = year + 5.5, y = gdp - 35, label = paste(after_stat(eq.label), after_stat(rr.label), after_stat(p.value.label), sep = "*\", \"*")), formula = y ~ x, parse = TRUE, color = "#3c5488", geom = "text_repel", size = 3, angle = 60) -> p1 p1
|
评论