corybrunson / ggalluvial

ggplot2 extension for alluvial plots
http://corybrunson.github.io/ggalluvial/
GNU General Public License v3.0
497 stars 34 forks source link

alluvial diagram vignette doesn't reproduce #29

Closed trippcm closed 5 years ago

trippcm commented 5 years ago

Description of the issue

I've been using ggaluvial to make alluvial diagrams, but for some reason today (and I don't know if this is related to package updates or what) my diagrams have changed to include this "background color." I'll show what I mean by including the code below, the original figure, which has grey "blank space" in between flows, and the figure I get when I run this code on my computer. I'd like to be able to get the figure looking like the original and have been fiddling for hours with no success. Thanks for any guidance!

Reproducible example

code from https://cloud.r-project.org/web/packages/ggalluvial/vignettes/ggalluvial.html

data(vaccinations) 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")

original image

screen shot 2019-01-29 at 12 52 36 pm

my image when I run the same code.

plot_zoom_png

corybrunson commented 5 years ago

Hi @trippcm, thanks for raising this issue. The problem looks from your plot to be that multiple flows are being rendered between the strata of adjacent axes, as though more than one alluvium or flow layer were being rendered. I've run the code on my machine using both the current CRAN release and the current master branch on GitHub, and i don't reproduce the problem. Could you reproduce your problem in a fresh R session, attaching only the ggalluvial package, and post the output of sessioninfo::session_info()? This may help us identify a package update or conflict that's not evident from the code above. Thanks!

trippcm commented 5 years ago

Hi @corybrunson , thank you for offering to look into this. I have never raised an issue on GitHub before, so I apologize if screenshots are an amateur way of doing so.. let me know if you'd like this in another format. I started a fresh R session and ran the code as you suggested.

code for alluvial plot and output

screen shot 2019-01-29 at 2 53 28 pm

sessioninfo::session_info() gives

screen shot 2019-01-29 at 2 54 06 pm
corybrunson commented 5 years ago

Thanks, @trippcm, this is fine for now! As you have time, i suggest experimenting with the reprex package, which helps produce reproducible examples that can be copy–pasted into these issue windows. (It's more efficient than copy–pasting code manually, and it's more effective than screenshots since other users can easily copy the code you post.)

There were some issues with an older version of ggalluvial that i thought might be the problem, but i'm still not able to reproduce the bad behavor. It looks from your screenshot that the problem arises from the vaccinations data somehow being expanded to thousands of rows, 7308 of which contain missing values. I'm not sure why this would be.

I'm not especially adept at debugging, but i suggest trying two things: First, re-install ggalluvial, either the CRAN version (install.packages("ggalluvial")) or from the current GitHub master branch (remotes::install_github("corybrunson/ggalluvial")), and execute the code again. Second, try installing the CRAN version of dplyr; it's unlikely, but v0.8.0 might have a bug that's arising in the ggalluvial internals.

trippcm commented 5 years ago

Hi @corybrunson , I re-installed ggalluvial and dplyr, re-ran the code, and now it works perfectly (reproduces the figure as it should be). I sincerely appreciate your help!!

corybrunson commented 5 years ago

Great! Thanks for the confirmation.