New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sankey diagrams/transition plots as a ggplot2 extension #6

Closed
timchurches opened this Issue Oct 6, 2017 · 7 comments

Comments

Projects
None yet
2 participants
@timchurches

timchurches commented Oct 6, 2017

Port or re-implement static Sankey diagrams/Parallel Co-ordinate Plots (see https://cran.r-project.org/web/packages/alluvial/vignettes/alluvial.html ) and/or transition plots (see https://cran.r-project.org/web/packages/Gmisc/vignettes/transitionPlot.html ) to the ggplot2 environment as an extension geom.

See p37 onwards in this report for examples of transition plots in use: http://www.acornregistry.org/images/Acorn-Annual-Report-2016-v12.pdf

There are also the riverplot and sankey packages (see https://cran.r-project.org/web/packages/riverplot/riverplot.pdf and https://cran.r-project.org/web/packages/sankey/sankey.pdf), and gvisSankey in the googleVis package (see https://www.rdocumentation.org/packages/googleVis/versions/0.6.0/topics/gvisSankey). None of these work with the ggplot2 ecosystem.

@njtierney

This comment has been minimized.

Show comment
Hide comment
@njtierney

njtierney Oct 6, 2017

Collaborator

I do love sankey charts - I wonder if we need to consider a data-preprocessing step here as well, to get things into the right format? @dicook any thoughts?

Collaborator

njtierney commented Oct 6, 2017

I do love sankey charts - I wonder if we need to consider a data-preprocessing step here as well, to get things into the right format? @dicook any thoughts?

@timchurches

This comment has been minimized.

Show comment
Hide comment
@timchurches

timchurches Oct 6, 2017

Yes, for a Sankey extension to ggplot2, an important issue is how it fits into the whole tidy data/dplyr functional programming paradigm, and whether it might be useful to add some helper functions to, say, the purrr package to make pipelined data preparation easier, as you suggest. The transitionPlot() in the Gmisc package requires the data to be transformed into a transition matrix, as a matrix object. Not difficult, but it feels out-of-step when doing everything else with ggplot2 and data frames/tibbles.

timchurches commented Oct 6, 2017

Yes, for a Sankey extension to ggplot2, an important issue is how it fits into the whole tidy data/dplyr functional programming paradigm, and whether it might be useful to add some helper functions to, say, the purrr package to make pipelined data preparation easier, as you suggest. The transitionPlot() in the Gmisc package requires the data to be transformed into a transition matrix, as a matrix object. Not difficult, but it feels out-of-step when doing everything else with ggplot2 and data frames/tibbles.

@njtierney

This comment has been minimized.

Show comment
Hide comment
@njtierney

njtierney Oct 12, 2017

Collaborator

By chance there has been some discussion on Twitter about Sankey charts: https://twitter.com/Md_Harris/status/915388811185721344 Might be of use!

Collaborator

njtierney commented Oct 12, 2017

By chance there has been some discussion on Twitter about Sankey charts: https://twitter.com/Md_Harris/status/915388811185721344 Might be of use!

@timchurches

This comment has been minimized.

Show comment
Hide comment
@timchurches

timchurches Oct 12, 2017

Ah, OK, I didn't know about ggalluvial, and or geom_parallel_sets in ggforce. Looks like Sankey diagrams in ggplot2 is a solved problem. But I'm now reminded how useful ggforce is. Maybe there are some other ggplot2 customisations or extensions that could be considered? More thinking...

timchurches commented Oct 12, 2017

Ah, OK, I didn't know about ggalluvial, and or geom_parallel_sets in ggforce. Looks like Sankey diagrams in ggplot2 is a solved problem. But I'm now reminded how useful ggforce is. Maybe there are some other ggplot2 customisations or extensions that could be considered? More thinking...

@timchurches

This comment has been minimized.

Show comment
Hide comment
@timchurches

timchurches Oct 22, 2017

ggalluvial works quite well, although with some minor artefacts in the plotting of the transition streams:

screen shot 2017-10-22 at 17 32 58

timchurches commented Oct 22, 2017

ggalluvial works quite well, although with some minor artefacts in the plotting of the transition streams:

screen shot 2017-10-22 at 17 32 58

@timchurches

This comment has been minimized.

Show comment
Hide comment
@timchurches

timchurches Oct 22, 2017

I didn't have any success with the geom_parallel_sets() geom in the ggforce package, but perhaps that's because it seems to be set up for true Sankey diagrams, whereas what I wanted was actually an alluvial diagram, as above. Anyway, I'll submit an issue report regarding the flaws in the ggalluvial output, but it is nonetheless good enough, and the package easy enough to use, to declare this a solved problem, I think.

timchurches commented Oct 22, 2017

I didn't have any success with the geom_parallel_sets() geom in the ggforce package, but perhaps that's because it seems to be set up for true Sankey diagrams, whereas what I wanted was actually an alluvial diagram, as above. Anyway, I'll submit an issue report regarding the flaws in the ggalluvial output, but it is nonetheless good enough, and the package easy enough to use, to declare this a solved problem, I think.

@njtierney

This comment has been minimized.

Show comment
Hide comment
@njtierney

njtierney Oct 23, 2017

Collaborator

@timchurches it sounds like this is wrapped up, are you happy to close this?

Collaborator

njtierney commented Oct 23, 2017

@timchurches it sounds like this is wrapped up, are you happy to close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment