如何更改 geom_flow ggplot 中的透明度?

How to change transparency in geom_flow ggplot?

我正在尝试更改冲积地块的流动元素的透明度。我知道我应该更改 'alpha' 的值,但我不确定我必须在代码中的哪个位置添加此参数。以下是我的代码:

library(ggplot2)
library(ggalluvial)

ggplot(sp.alluvial, aes(x = stage, stratum = state, alluvium = pks, fill = state, label = state)) +
  scale_fill_brewer(type = "qual", palette = "Set2") +
  geom_flow(stat = "alluvium", lode.guidance = "frontback", aes(fill = state), aes.flow = "backward") + 
  geom_stratum() +
  theme(legend.position = "bottom", axis.text.y = element_blank(), axis.ticks.y = element_blank()) 

我已经尝试了下一个选项:

geom_flow(stat = "alluvium", lode.guidance = "frontback", aes(fill = state), aes.flow = "backward", alpha = 0.6)

geom_flow(stat = "alluvium", lode.guidance = "frontback", aes(fill = state, alpha = 0.6), aes.flow = "backward")

+ geom_density(alpha = 0.6)

有什么想法吗?

谢谢!

以下似乎有效。
该图基于 geom_lode 中的第二个示例,因为该问题没有已发布的数据集。

我用 alpha 参数 0.20.8 的不同值绘制了相同的图,并且流的透明度确实发生了变化。

library(ggplot2)
library(ggalluvial)

gg <- ggplot(as.data.frame(Titanic),
             aes(y = Freq, 
                 axis1 = Class, axis2 = Sex, axis3 = Age,
                 fill = Survived))

gg + 
  geom_flow(alpha = 0.5) + 
  geom_stratum() + 
  geom_lode() + 
  geom_text(stat = "stratum", infer.label = TRUE)