我正在尝试更改冲积积块的流动要素的透明度。我知道我应该更改'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)
有什么想法吗?
谢谢!
答案 0 :(得分:0)
以下似乎有效。
由于问题没有发布的数据集,因此该图基于geom_lode
中的第二个示例。
我用alpha
参数0.2
和0.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)