{"id":13858109,"url":"https://github.com/corybrunson/ggalluvial","last_synced_at":"2026-02-22T15:15:52.793Z","repository":{"id":44726227,"uuid":"59313744","full_name":"corybrunson/ggalluvial","owner":"corybrunson","description":"ggplot2 extension for alluvial plots","archived":false,"fork":false,"pushed_at":"2024-12-13T15:04:04.000Z","size":126026,"stargazers_count":508,"open_issues_count":15,"forks_count":34,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-04T23:02:17.258Z","etag":null,"topics":["alluvial-diagrams","alluvial-plots","categorical-data-visualization","ggplot2","r","repeated-measures-data"],"latest_commit_sha":null,"homepage":"http://corybrunson.github.io/ggalluvial/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/corybrunson.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-20T17:34:43.000Z","updated_at":"2025-03-11T06:54:23.000Z","dependencies_parsed_at":"2023-02-19T02:15:58.279Z","dependency_job_id":"676447cf-9bc5-4eb7-88bd-632b10d7c47f","html_url":"https://github.com/corybrunson/ggalluvial","commit_stats":{"total_commits":662,"total_committers":7,"mean_commits":94.57142857142857,"dds":"0.40030211480362543","last_synced_commit":"64f66302a2f2499836d9d1d33e4aa4e387eb8897"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corybrunson%2Fggalluvial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corybrunson%2Fggalluvial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corybrunson%2Fggalluvial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corybrunson%2Fggalluvial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/corybrunson","download_url":"https://codeload.github.com/corybrunson/ggalluvial/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248383214,"owners_count":21094581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alluvial-diagrams","alluvial-plots","categorical-data-visualization","ggplot2","r","repeated-measures-data"],"created_at":"2024-08-05T03:01:56.956Z","updated_at":"2026-02-22T15:15:52.785Z","avatar_url":"https://github.com/corybrunson.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"\n\u003c!-- README.md is generated from README.rmd. Please edit that file --\u003e\n\n# ggalluvial\n\n[![Travis](https://api.travis-ci.com/corybrunson/ggalluvial.svg?branch=main)](https://app.travis-ci.com/corybrunson/ggalluvial)\n[![CRAN](http://www.r-pkg.org/badges/version/ggalluvial)](https://cran.r-project.org/package=ggalluvial)\n[![downloads](https://cranlogs.r-pkg.org/badges/ggalluvial)](https://cran.r-project.org/package=ggalluvial)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3836748.svg)](https://doi.org/10.5281/zenodo.3836747)\n[![JOSS](https://joss.theoj.org/papers/10.21105/joss.02017/status.svg)](https://doi.org/10.21105/joss.02017)\n\nThis is a [{ggplot2} extension](https://exts.ggplot2.tidyverse.org/) for\nalluvial plots.\n\n## Design\n\nThe alluvial plots implemented here can be used to visualize frequency\ndistributions over time or frequency tables involving several\ncategorical variables. The design is inspired by the\n[{alluvial}](https://github.com/mbojan/alluvial) package, but the\n{ggplot2} framework induced several conspicuous differences:\n\n- {alluvial} understands a variety of inputs (vectors, lists, data\n  frames), whereas {ggalluvial} requires a single data frame;\n- {alluvial} uses each variable of these inputs as a dimension of the\n  data, whereas {ggalluvial} requires the user to specify the\n  dimensions, either as separate aesthetics or as [key-value\n  pairs](https://tidyr.tidyverse.org/);\n- {alluvial} produces both the *alluvia*, which link cohorts across\n  multiple dimensions, and (what are here called) the *strata*, which\n  partition the data along each dimension, in a single function; whereas\n  {ggalluvial} relies on separate layers (stats and geoms) to produce\n  strata, alluvia, and alluvial segments called *lodes* and *flows*.\n\nAdditionally, {ggalluvial} arranges these layers vertically without\ngaps, so that the secondary plotting axis indicates the cumulative\nvalues of the strata at each dimension.\n\n## Installation\n\nThe latest stable release can be installed from CRAN:\n\n``` r\ninstall.packages(\"ggalluvial\")\n```\n\nThe [`cran` branch](https://github.com/corybrunson/ggalluvial/tree/cran)\nwill contain the version most recently submitted to\n[CRAN](https://cran.r-project.org/package=ggalluvial). It is duplicated\nin the `master` branch, from which source the\n[website](https://corybrunson.github.io/ggalluvial/) is built.\n\nThe development version can be installed from the (default) `main`\nbranch on GitHub:\n\n``` r\nremotes::install_github(\"corybrunson/ggalluvial@main\", build_vignettes = TRUE)\n```\n\nNote that, in order to build the vignettes, the imported packages\n{alluvial}, {ggfittext}, and {ggrepel} must be installed. To skip this\nstep, leave `build_vignettes` unspecified or set it to `FALSE`.\n\nThe [`optimization`\nbranch](https://github.com/corybrunson/ggalluvial/tree/optimization)\ncontains a development version with experimental functions to reduce the\nnumber or area of alluvial overlaps (see issue\n[\\#6](https://github.com/corybrunson/ggalluvial/issues/6)). Install it\nas follows:\n\n``` r\nremotes::install_github(\"corybrunson/ggalluvial\", ref = \"optimization\")\n```\n\nNote, however, that this branch has not kept pace with the `main` branch\nor with recent upgrades on CRAN.\n\n## Usage\n\n### Example\n\nHere is how to generate an alluvial plot representation of the\nmulti-dimensional categorical dataset of passengers on the Titanic:\n\n``` r\ntitanic_wide \u003c- data.frame(Titanic)\nhead(titanic_wide)\n#\u003e   Class    Sex   Age Survived Freq\n#\u003e 1   1st   Male Child       No    0\n#\u003e 2   2nd   Male Child       No    0\n#\u003e 3   3rd   Male Child       No   35\n#\u003e 4  Crew   Male Child       No    0\n#\u003e 5   1st Female Child       No    0\n#\u003e 6   2nd Female Child       No    0\nggplot(data = titanic_wide,\n       aes(axis1 = Class, axis2 = Sex, axis3 = Age,\n           y = Freq)) +\n  scale_x_discrete(limits = c(\"Class\", \"Sex\", \"Age\"), expand = c(.2, .05)) +\n  xlab(\"Demographic\") +\n  geom_alluvium(aes(fill = Survived)) +\n  geom_stratum() +\n  geom_text(stat = \"stratum\", aes(label = after_stat(stratum))) +\n  theme_minimal() +\n  ggtitle(\"passengers on the maiden voyage of the Titanic\",\n          \"stratified by demographics and survival\")\n```\n\n![](man/figures/README-unnamed-chunk-6-1.png)\u003c!-- --\u003e\n\nThe data is in “wide” format, but {ggalluvial} also recognizes data in\n“long” format and can convert between the two:\n\n``` r\ntitanic_long \u003c- to_lodes_form(data.frame(Titanic),\n                              key = \"Demographic\",\n                              axes = 1:3)\nhead(titanic_long)\n#\u003e   Survived Freq alluvium Demographic stratum\n#\u003e 1       No    0        1       Class     1st\n#\u003e 2       No    0        2       Class     2nd\n#\u003e 3       No   35        3       Class     3rd\n#\u003e 4       No    0        4       Class    Crew\n#\u003e 5       No    0        5       Class     1st\n#\u003e 6       No    0        6       Class     2nd\nggplot(data = titanic_long,\n       aes(x = Demographic, stratum = stratum, alluvium = alluvium,\n           y = Freq, label = stratum)) +\n  geom_alluvium(aes(fill = Survived)) +\n  geom_stratum() + geom_text(stat = \"stratum\") +\n  theme_minimal() +\n  ggtitle(\"passengers on the maiden voyage of the Titanic\",\n          \"stratified by demographics and survival\")\n```\n\n![](man/figures/README-unnamed-chunk-7-1.png)\u003c!-- --\u003e\n\n### Documentation\n\nFor detailed discussion of the data formats recognized by {ggalluvial}\nand several examples that illustrate its flexibility and limitations,\nread the technical vignette:\n\n``` r\nvignette(topic = \"ggalluvial\", package = \"ggalluvial\")\n```\n\nSeveral additional vignettes offer detailed solutions to specific needs:\n\n- “Labeling small strata” (`\"labels\"`) for how to elegantly label strata\n  of a wide range of heights in an alluvial plot;\n- “The Order of the Rectangles” (`\"order-rectangles\"`) for how to\n  control the positioning of strata and lodes in an alluvial plot; and\n- “Tooltips for ggalluvial plots in Shiny apps” (`\"shiny\"`) for how to\n  incorporate alluvial plots into interactive apps.\n\nThe object documentation includes several more examples. Use `help()` to\ncall forth more detail on\n\n- any layer (`stat_*` or `geom_*`),\n- the conversion functions (`to_*_form`), and\n- the data sets installed with the package (`vaccinations` and\n  `majors`).\n\n### Short form\n\nFor some more digestible guidance on using {ggalluvial}, check out three\ncheat sheets and demos by students in Joyce Robbins’s [Exploratory Data\nAnalysis and Visualization Community Contribution\nProject](https://jtr13.github.io/cc21fall2/index.html):\n\n- an\n  [introduction](https://jtr13.github.io/cc21fall2/ggalluvial-cheatsheet.html)\n  by Meggie Wen (Chapter 33)\n- a [cheat\n  sheet](https://cheatography.com/seleven/cheat-sheets/ggalluvial/) by\n  Qingyi Zhang (Chapter 14)\n\n## Acknowledgments\n\n### Resources\n\nDevelopment of this package benefitted from the use of equipment and the\nsupport of colleagues at [UConn Health](https://health.uconn.edu/) and\nat [UF Health](https://ufhealth.org/).\n\n### Contribute\n\nContributions in any form are more than welcome! Pretty much every fix\nand feature of this package derives from a problem or question posed by\nsomeone with datasets or design goals i hadn’t anticipated. See the\n[CONTRIBUTING](https://github.com/corybrunson/ggalluvial/blob/main/CONTRIBUTING.md)\nfile for guidance, and please respect the [Code of\nConduct](https://github.com/corybrunson/ggalluvial/blob/main/CODE_OF_CONDUCT.md).\n\n### Cite\n\nIf you use {ggalluvial}-generated figures in publication, i’d be\ngrateful to hear about it! You can also cite the package according to\n`citation(\"ggalluvial\")`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorybrunson%2Fggalluvial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorybrunson%2Fggalluvial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorybrunson%2Fggalluvial/lists"}