[英]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.