1

I was wondering how we could align the x-axis with the zero on the y-axis. I tried adjusting the limits, with ylim(0, 1000), however that does not seem to work.

library(ggalluvial)
data(vaccinations)

vaccinations <- vaccinations[-c(94),]
levels(vaccinations$response) <- rev(levels(vaccinations$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")

See the plot here, with a blue marker, marking the space that I would like to remove.

enter image description here

Snowflake
  • 2,869
  • 3
  • 22
  • 44

1 Answers1

1
ggplot(vaccinations,
           aes(x = survey, stratum = response, alluvium = subject,
               y = freq,
               fill = response, label = response)) +
      scale_x_discrete(expand = c(.1, .1)) +
      #adjust the y scale:
      scale_y_continuous(expand = c(0, 0), limits = c(0, 1000)) +
      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")

resulting plot

Roland
  • 127,288
  • 10
  • 191
  • 288