我尝试了以下代码,但不是在中间显示标签,而是想将它指向最左边(你可以在下面看到我的图片)。谢谢您的帮助!
library(tidyverse)
library(ggrepel)
mtcars %>%
group_by(am, cyl) %>%
slice(1) %>%
ggplot(aes(x = am, y = mpg, group = cyl, fill = cyl, label = mpg)) +
geom_bar(position = "dodge", stat = "identity") +
geom_label_repel(data = mtcars %>% filter(am == 0,
cyl == 4) %>%
slice(1),
nudge_x = 0.2,
nudge_y = 0.3,
aes(fill = NULL))
由reprex 包(v0.2.1)于 2019 年 1 月 22 日创建