我有一个气泡图,我正在使用 ggrepel 来避免标签重叠。
可重现的例子:
library(randomcoloR)
n <- nrow(iris)
palette <- unname(distinctColorPalette(n))
(p <- iris %>%
ggplot(aes(x=Sepal.Length,
y=Sepal.Width,
label = Species,
color = palette)) +
geom_point(alpha = 0.7, show.legend = FALSE) +
scale_color_manual(values=palette)
)
(r <-
p + geom_point(
aes(size = Petal.Length*Petal.Width),
pch = 21,
show.legend = FALSE,
fill = palette
) +
scale_size_continuous(range = c(2, 30)) +
geom_text_repel(segment.color = "orange",
nudge_y = 0.05,
angle = 0,
vjust = -5,
segment.size = 0.2) +
theme(legend.position = "none")
)
问题是我希望标签与气泡颜色相同,但我得到的是圆形边框的颜色。