我想突出显示散点图中的 4 个单点,并在与该图关联的名称周围有一个框。我正在使用 ggrepel 创建围绕地块的框并击退它们。
这是我的代码:
library(ggplot2)
gg <- ggplot(X, aes(x = XX, y = XY)) +
geom_point(col = "steelblue", size = 3) +
geom_smooth(method = "lm", col = "firebrick", se = FALSE) +
labs(title = "XX vs XY", subtitle = "X", y = "XX", x = "XY") +
scale_x_continuous(breaks = seq(76, 82, 1)) +
scale_y_continuous(breaks = seq(15, 19, 1))
library(ggrepel)
gg + geom_text_repel(aes(label = Female), size = 3, data = X)
gg + geom_label_repel(aes(label = Female), size = 2, data = X)
使用该代码,我获得了围绕所有地块的框。但是,我只想在 4 个特定地块中有框,而在其他地块中没有框。我怎样才能做到这一点?
提前致谢!问候, TD