簡體   English   中英

ggrepel 刪除標簽周圍的線

[英]ggrepel remove line around labels

如何刪除geom_label_repel周圍的線。 使用label.size = 0似乎沒有明顯效果。 我可以設置`顏色

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_text_repel之后輸入geom_label_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)))

在此處輸入圖片說明

另外,根據幫助頁面:

目前geom_label_repel ... 比geom_text_repel慢得多。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM