05 ) ) + scale_fill_brewer (type = "qual", palette = "Set1" ) + ggtitle ( "UC Berkeley admissions and rejections, by sex and department" )Īn important feature of these plots is the meaningfulness of the vertical axis: No gaps are inserted between the strata, so the total height of the plot reflects the cumulative quantity of the observations. Ggplot ( as.ame ( UCBAdmissions ),Īes (y = Freq, axis1 = Gender, axis2 = Dept ) ) + geom_alluvium ( aes (fill = Admit ), width = 1 / 12 ) + geom_stratum (width = 1 / 12, fill = "black", color = "grey" ) + geom_label (stat = "stratum", aes (label = after_stat ( stratum ) ) ) + scale_x_discrete (limits = c ( "Gender", "Dept" ), expand = c (. The lodes are not visualized in the above plot, but they can be inferred as filled rectangles extending the flows through the strata at each end of the plot or connecting the flows on either side of the center stratum.Īs the examples in the next section will demonstrate, which of these elements are incorporated into an alluvial plot depends on both how the underlying data is structured and what the creator wants the plot to communicate. The alluvia intersect the strata at lodes.The segments of the alluvia between pairs of adjacent axes are flows.In this plot, each alluvium corresponds to a fixed value of each axis variable, indicated by its vertical position at the axis, as well as of the Survived variable, indicated by its fill color. Horizontal (x-) splines called alluvia span the width of the plot.For example, the Class axis contains four strata: 1st, 2nd, 3rd, and Crew. The groups at each axis are depicted as opaque blocks called strata.The plot above uses three categorical axes: Class, Sex, and Age.
illustrates the new stats and geoms, and.
describes the alluvial data structures recognized by ggalluvial,.defines the essential components of alluvial plots as used in the naming schemes and documentation ( axis, alluvium, stratum, lode, flow),.The design and functionality were originally inspired by the alluvial package and have benefitted from the feedback of many users. The ggalluvial package is a ggplot2 extension for producing alluvial plots in a tidyverse framework.