1

我正在尝试改变冲积地块流动元素的透明度。我知道我应该更改 '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)

有任何想法吗?

谢谢!

4

1 回答 1

1

以下似乎有效。
该图基于 中的第二个示例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)

在此处输入图像描述

于 2020-06-30T06:28:16.060 回答