ggalluvial
ggalluvial: Layered Grammar for Alluvial Plots - Published in JOSS (2020)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 7 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
✓Committers with academic emails
2 of 7 committers (28.6%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Repository
ggplot2 extension for alluvial plots
Basic Info
- Host: GitHub
- Owner: corybrunson
- License: gpl-3.0
- Language: R
- Default Branch: main
- Homepage: http://corybrunson.github.io/ggalluvial/
- Size: 128 MB
Statistics
- Stars: 513
- Watchers: 13
- Forks: 34
- Open Issues: 21
- Releases: 13
Topics
Metadata Files
README.md
ggalluvial
This is a ggplot2 extension for alluvial plots.
Design
The alluvial plots implemented here can be used to visualize frequency distributions over time or frequency tables involving several categorical variables. The design is inspired by the alluvial package, but the ggplot2 framework induced several conspicuous differences:
- alluvial understands a variety of inputs (vectors, lists, data frames), whereas ggalluvial requires a single data frame;
- alluvial uses each variable of these inputs as a dimension of the data, whereas ggalluvial requires the user to specify the dimensions, either as separate aesthetics or as key-value pairs;
- alluvial produces both the alluvia, which link cohorts across multiple dimensions, and (what are here called) the strata, which partition the data along each dimension, in a single function; whereas ggalluvial relies on separate layers (stats and geoms) to produce strata, alluvia, and alluvial segments called lodes and flows.
Additionally, ggalluvial arranges these layers vertically without gaps, so that the secondary plotting axis indicates the cumulative values of the strata at each dimension.
Installation
The latest stable release can be installed from CRAN:
r
install.packages("ggalluvial")
The cran branch
will contain the version most recently submitted to
CRAN. It is duplicated
in the master branch, from which source the
website is built.
The development version can be installed from the (default) main
branch on GitHub:
r
remotes::install_github("corybrunson/ggalluvial@main", build_vignettes = TRUE)
Note that, in order to build the vignettes, the imported packages
alluvial, ggfittext, and ggrepel must be installed. To skip
this step, leave build_vignettes unspecified or set it to FALSE.
The optimization
branch
contains a development version with experimental functions to reduce the
number or area of alluvial overlaps (see issue
#6). Install it
as follows:
r
remotes::install_github("corybrunson/ggalluvial", ref = "optimization")
Note, however, that this branch has not kept pace with the main branch
or with recent upgrades on CRAN.
Usage
Example
Here is how to generate an alluvial plot representation of the multi-dimensional categorical dataset of passengers on the Titanic:
``` r titanicwide <- data.frame(Titanic) head(titanicwide)
> Class Sex Age Survived Freq
> 1 1st Male Child No 0
> 2 2nd Male Child No 0
> 3 3rd Male Child No 35
> 4 Crew Male Child No 0
> 5 1st Female Child No 0
> 6 2nd Female Child No 0
ggplot(data = titanicwide, aes(axis1 = Class, axis2 = Sex, axis3 = Age, y = Freq)) + scalexdiscrete(limits = c("Class", "Sex", "Age"), expand = c(.2, .05)) + xlab("Demographic") + geomalluvium(aes(fill = Survived)) + geomstratum() + geomtext(stat = "stratum", aes(label = afterstat(stratum))) + thememinimal() + ggtitle("passengers on the maiden voyage of the Titanic", "stratified by demographics and survival") ```
<!-- -->
The data is in “wide” format, but ggalluvial also recognizes data in “long” format and can convert between the two:
``` r titaniclong <- tolodesform(data.frame(Titanic), key = "Demographic", axes = 1:3) head(titaniclong)
> Survived Freq alluvium Demographic stratum
> 1 No 0 1 Class 1st
> 2 No 0 2 Class 2nd
> 3 No 35 3 Class 3rd
> 4 No 0 4 Class Crew
> 5 No 0 5 Class 1st
> 6 No 0 6 Class 2nd
ggplot(data = titaniclong, aes(x = Demographic, stratum = stratum, alluvium = alluvium, y = Freq, label = stratum)) + geomalluvium(aes(fill = Survived)) + geomstratum() + geomtext(stat = "stratum") + theme_minimal() + ggtitle("passengers on the maiden voyage of the Titanic", "stratified by demographics and survival") ```
<!-- -->
Documentation
For detailed discussion of the data formats recognized by ggalluvial and several examples that illustrate its flexibility and limitations, read the technical vignette:
r
vignette(topic = "ggalluvial", package = "ggalluvial")
Several additional vignettes offer detailed solutions to specific needs:
- “Labeling small strata” (
"labels") for how to elegantly label strata of a wide range of heights in an alluvial plot; - “The Order of the Rectangles” (
"order-rectangles") for how to control the positioning of strata and lodes in an alluvial plot; and - “Tooltips for ggalluvial plots in Shiny apps” (
"shiny") for how to incorporate alluvial plots into interactive apps.
The object documentation includes several more examples. Use help() to
call forth more detail on
- any layer (
stat_*orgeom_*), - the conversion functions (
to_*_form), and - the data sets installed with the package (
vaccinationsandmajors).
Short form
For some more digestible guidance on using ggalluvial, check out three cheat sheets and demos by students in Joyce Robbins’s Exploratory Data Analysis and Visualization Community Contribution Project:
- an introduction by Meggie Wen (Chapter 33)
- a cheat sheet by Qingyi Zhang (Chapter 14)
- a blog about how this package implements alluvial plots by Arnav Saxena (Chapter 134)
Acknowledgments
Resources
Development of this package benefitted from the use of equipment and the support of colleagues at UConn Health and at UF Health.
Contribute
Contributions in any form are more than welcome! Pretty much every fix and feature of this package derives from a problem or question posed by someone with datasets or design goals i hadn’t anticipated. See the CONTRIBUTING file for guidance, and please respect the Code of Conduct.
Cite
If you use ggalluvial-generated figures in publication, i’d be
grateful to hear about it! You can also cite the package according to
citation("ggalluvial").
Owner
- Name: Cory Brunson
- Login: corybrunson
- Kind: user
- Location: Gainesville, FL
- Company: @LaboratoryForSystemsMedicine
- Website: http://systemsmedicine.pulmonary.medicine.ufl.edu/profile/brunson-jason/
- Twitter: cornelioid
- Repositories: 14
- Profile: https://github.com/corybrunson
Mathematician by training, data scientist by testing. Relatively new to pretty much everything.
JOSS Publication
ggalluvial: Layered Grammar for Alluvial Plots
Tags
ggplot2 alluvial plots statistical graphics data visualization repeated measures data categorical dataGitHub Events
Total
- Issues event: 15
- Watch event: 15
- Issue comment event: 27
- Push event: 1
- Create event: 1
Last Year
- Issues event: 15
- Watch event: 15
- Issue comment event: 27
- Push event: 1
- Create event: 1
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| corybrunson | j****o@v****u | 397 |
| Jason Cory Brunson | c****d@g****m | 218 |
| Quentin Read | q****d@g****m | 33 |
| corybrunson | c****n@c****l | 6 |
| Cory Brunson | b****n@u****u | 5 |
| Brunson | j****n@F****l | 3 |
| Michael Chirico | m****4@g****m | 2 |
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 127
- Total pull requests: 10
- Average time to close issues: 4 months
- Average time to close pull requests: 19 days
- Total issue authors: 83
- Total pull request authors: 2
- Average comments per issue: 3.82
- Average comments per pull request: 5.9
- Merged pull requests: 10
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 13
- Pull requests: 0
- Average time to close issues: about 1 month
- Average time to close pull requests: N/A
- Issue authors: 9
- Pull request authors: 0
- Average comments per issue: 1.69
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- corybrunson (33)
- SimonDedman (3)
- dcarbajo (3)
- qdread (3)
- peter308 (3)
- jasonpott (2)
- plijnzaad (2)
- mbojan (2)
- Generalized (2)
- hmlea (1)
- elbamos (1)
- abiyug (1)
- SaintRod (1)
- twedl (1)
- AdrianS85 (1)
Pull Request Authors
- qdread (6)
- MichaelChirico (4)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- cran 20,693 last-month
- Total docker downloads: 27,136
-
Total dependent packages: 13
(may contain duplicates) -
Total dependent repositories: 84
(may contain duplicates) - Total versions: 31
- Total maintainers: 1
proxy.golang.org: github.com/corybrunson/ggalluvial
- Documentation: https://pkg.go.dev/github.com/corybrunson/ggalluvial#section-documentation
- License: gpl-3.0
-
Latest release: v0.12.2
published over 5 years ago
Rankings
cran.r-project.org: ggalluvial
Alluvial Plots in 'ggplot2'
- Homepage: http://corybrunson.github.io/ggalluvial/
- Documentation: http://cran.r-project.org/web/packages/ggalluvial/ggalluvial.pdf
- License: GPL-3
-
Latest release: 0.12.5
published almost 3 years ago
Rankings
Maintainers (1)
conda-forge.org: r-ggalluvial
- Homepage: https://cloud.r-project.org/package=ggalluvial
- License: GPL-3.0-only
-
Latest release: 0.12.3
published about 5 years ago
Rankings
Dependencies
- actions/checkout v2 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- R >= 3.5 depends
- ggplot2 >= 2.2 depends
- dplyr >= 0.7 imports
- lazyeval * imports
- rlang * imports
- stats * imports
- tidyr >= 0.7 imports
- tidyselect * imports
- alluvial * suggests
- babynames * suggests
- ggfittext >= 0.6 suggests
- ggrepel * suggests
- grid * suggests
- htmltools * suggests
- knitr * suggests
- rmarkdown * suggests
- sessioninfo * suggests
- shiny >= 1.4.0.2 suggests
- sp >= 1.4 suggests
- testthat * suggests
- vdiffr >= 0.2 suggests
