ggrepel 删除标签周围的线

ggrepel remove line around labels

如何删除 geom_label_repel 周围的线。使用 label.size = 0 似乎没有明显的效果。我可以设置`colour

library(ggplot2)
library(ggrepel)
ggplot(mtcars, aes(wt, mpg, color = wt)) +
  geom_point(color = 'red') +
  geom_label_repel(aes(label = rownames(mtcars)), label.size = 0, fill = "white") +
  theme_classic(base_size = 16)

在空白 geom_label_repel 之后输入 geom_text_repel 有时会奏效,但并不可靠:方框可能出现在与文本不同的位置。

正如 eipi10 在评论中指出的那样,设置 label.size=NA:

library(ggplot2)
library(ggrepel)
ggplot(mtcars, aes(wt, mpg, color = wt)) +
  geom_point(color = 'red') +
  geom_label_repel(aes(label = rownames(mtcars)), label.size = NA, fill = "white") +
  theme_classic(base_size = 16)

您可以使用 geom_text_repel geom 省略标签框。

library(ggplot2)
library(ggrepel)
g <- ggplot(mtcars, aes(wt, mpg, color = wt)) +
  geom_point(color = 'red') +
  theme_classic(base_size = 16)

g + geom_label_repel(aes(label = rownames(mtcars)), fill = "white")

g + geom_text_repel(aes(label = rownames(mtcars)))

此外,根据帮助页面:

Currently geom_label_repel ... is considerably slower than geom_text_repel.