4

I need to create a particular type of plot using ggalluvial. From the vignette of the package:

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

Gives this plot:

enter image description here

Now, I need to produce a plot in which two different "flows" from the first block of nodes "merge" (or converge) on the same portion of another node in the first block (for example, the flows from "always" and "sometimes" converge on the same part on the "always" second block). Obviously, the frequencies would be different from the first block and the second block of nodes.

I've tried to manipulate the database changing frequencies, but it seems there is no way to make two flows "converge" on the same section of the end node.

Anyone have a guess?

EDIT: To answer to the comment, this is the output that I have in mind (taken from another answer, here: Create Sankey/ Alluvial diagram in which the links combine at the node):

enter image description here

In which two "flow" (from the red and the green boxes) "converge" on the pink box (occupying the same place on the pink box).

userq8957289475
  • 297
  • 1
  • 11
  • 2
    would you care drawing your desired output? It's not clear to me how you want it to look like – tjebo Jun 19 '22 at 16:04
  • Thanks - this is clear now. I don't think this is possible with this package - I guess because the main idea of an alluvial chart is to show how proportions change between variables - and the "overlapping" alluvial chart would not be an accurate representation of the proportions any more. – tjebo Jun 19 '22 at 18:55
  • 1
    As @tjebo says, you can't do this with ggalluvial. You can draw an alluvial plot yourself from scratch with ribbons and rectangles as I demonstrated [here](https://stackoverflow.com/questions/62365650/r-question-how-to-mimic-this-graph-to-show-the-percent-change-of-cells-in-healt/62372948#62372948), and this would allow the freedom to have converging alluvia. However, it's a bit...involved. – Allan Cameron Jun 19 '22 at 19:57

0 Answers0