0

Hi suppose I have a figure like this. I don't care about the y-axis per se, however what I want is to have spaces in between each category, for example each response would be nice if it was seperated with a white space? I have a figure below with red drawing to illustrate what I mean. Is this possible? Data is loaded from the package.

  data(vaccinations)
    vaccinations$response <- factor(vaccinations$response,
                                    rev(levels(vaccinations$response)))
    # annotate with proportional counts
    ggplot(vaccinations,
           aes(x = survey, stratum = response, alluvium = subject,
               y = freq, fill = response)) +
      geom_lode() + geom_flow(curve_type = "cubic") +
      geom_stratum(alpha = 0) +
      geom_text(stat = "stratum", aes(label = round(after_stat(prop), 3))) +
      theme(axis.title.y=element_blank(),
            axis.text.y=element_blank(),
            axis.ticks.y=element_blank())

enter image description here

What I also tried is to increase the space between between the stacks however when I do that the flow does not align with the stack.

ggplot(vaccinations,
       aes(x = survey, stratum = response, alluvium = subject,
           y = freq, fill = response)) +
   geom_flow(curve_type = "cubic", knot.pos = FALSE, segments=3, lwd=10 ) +
  geom_stratum(alpha = 0, lwd=10, color="white" ) +
  geom_text(stat = "stratum", aes(label = round(after_stat(prop), 3))) +
  theme(axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())

now it looks like this notice how the flow does not align. enter image description here

Ahdee
  • 4,679
  • 4
  • 34
  • 58
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Sep 04 '21 at 02:12
  • Some relevant discussions: https://stackoverflow.com/questions/67113888/alluvial-plot-in-r-how-to-space-the-strata – MrFlick Sep 04 '21 at 02:26
  • I think the [accepted answer](https://stackoverflow.com/a/67114079/9664796) for the question @MrFlick referenced is going to be your answer. The OP there wanted the same thing and it seems it's not something alluvial plots are designed to do be definition. I believe `ggsankey` is going to work for you, as indicated over in that question. – chemdork123 Sep 04 '21 at 12:06

0 Answers0