小编INe*_*des的帖子

如何在 Alluvial/Sankey 图(在 R ggalluvial 上)的流量项上添加值标签?

我希望在 R 上标记冲积/桑基图的“流量”部分。

层(列)可以很容易地被标记,但连接它们的流却不能。我所有阅读文档和实验的尝试都没有成功。

在下面的示例中,“freq”预计会标记在流量连接部分上。

图表

library(ggplot2)
library(ggalluvial)

data(vaccinations)
levels(vaccinations$response) <- rev(levels(vaccinations$response))
ggplot(vaccinations,
       aes(x = survey, stratum = response, alluvium = subject,
           y = freq,
           fill = response, label = freq)) +
  scale_x_discrete(expand = c(.1, .1)) +
  geom_flow() +
  geom_stratum(alpha = .5) +
  geom_text(stat = "stratum", size = 3) +
  theme(legend.position = "bottom") +
  ggtitle("vaccination survey responses at three points in time")
Run Code Online (Sandbox Code Playgroud)

r data-visualization ggplot2 dataflow-diagram sankey-diagram

3
推荐指数
1
解决办法
6352
查看次数