下面有我的代码的简化版本。该段显示为半透明,如第二段覆盖的第一段所突出显示的那样,该段显示具有更多alpha的白色。
如果打开在Adobe Illustrator中另存为SVG的图像,则透明度设置为50%,这说明了为什么看起来像它,但是我不知道为什么当我未设置时将其设置为50%它(但将alpha设置为1)。
library(tidyverse)
g <- ggplot() +
theme_void() +
theme(
plot.background = element_rect(fill = "black"),
) +
#coord_polar() +
scale_color_identity() +
#plot distance - facing outwards
geom_segment(aes(x = 1, xend = 3,
y = 1, yend = 3,
colour = "white", alpha = 1),
size = 1, inherit.aes = FALSE) +
geom_segment(aes(x = 1, xend = 2,
y = 1, yend = 2,
colour = "white", alpha = 1),
size = 1, inherit.aes = FALSE)
g
我想您只需要将colour
和alpha
从aes
功能中移出即可。您编写它的方式是将它们作为要解释的变量而不是绝对值传递:
library(tidyverse)
g <- ggplot() +
theme_void() +
theme(
plot.background = element_rect(fill = "black"),
) +
#coord_polar() +
scale_color_identity() +
#plot distance - facing outwards
geom_segment(aes(x = 1, xend = 3,
y = 1, yend = 3),
colour = "white", alpha = 1,
size = 1, inherit.aes = FALSE) +
geom_segment(aes(x = 1, xend = 2,
y = 1, yend = 2),
colour = "white", alpha = 1,
size = 1, inherit.aes = FALSE)
g