我想创建一个 ggforce 注释(通过geom_mark_*
函数),但我不希望几何图形的形状可见。我尝试将各种 alpha 级别设置为零,但无济于事。换句话说,我想保留注释线和标签,而不是在下面的代表中环绕该点的圆圈。我该如何隐藏它?
编辑:针对以下一种可能的解决方案,我不能使用颜色参数,因为我有不止一种背景颜色。
library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 4.0.5
#> Warning: package 'dplyr' was built under R version 4.0.5
library(ggforce)
#> Warning: package 'ggforce' was built under R version 4.0.4
df2 <- tibble(
x = 1:10,
y = rnorm(10),
z = LETTERS[1:10]
)
ggplot(df2, aes(x, y)) +
geom_point() +
geom_mark_circle(
aes(label = z, filter = x == 5)
) +
annotate(
"rect",
xmin = 0,
xmax = 5,
ymin = -Inf,
ymax = Inf,
fill = "steelblue",
alpha = 0.3
) +
annotate(
"rect",
xmin = 5,
xmax = Inf,
ymin = -Inf,
ymax = Inf,
fill = "firebrick",
alpha = 0.3
)
由reprex 包(v1.0.0)于 2021 年 9 月 2 日创建