title: ggalluvial package in R - Setting alluvial fill color axis by axis (rather than solely by final axis)
body: <p>I am currently trying to produce an alluvial plot in R with the <a href="https://cran.r-project.org/web/packages/ggalluvial/index.html" rel="nofollow noreferrer"><code>ggalluvial</code> package</a>.  With it I wish to plot the successive migration across multiple between different values across successive segments of time (Seg1, Seg2, Seg3, Seg4). At Seg 1 all cases have the value of "workseg"; at Seg 2 the value may be one of three other values (related content, unrelated content, NONE); Seg3 and Seg4 values can be any of the four options.</p>
  
  <p>Using the following code...</p>
  
  <pre><code>##Reorder levels per segment (make vertical order of strata levels identical 
  across all axes, rather than "zig-zag" --&gt; this is just an aesthetic 
  preference)##
  
  dRG.lode &lt;- dRG %&gt;%
    mutate(Seg2 = factor(Seg2, levels=c("workseg", "related content", 
  "unrelated content", "NONE")),
           Seg3 = factor(Seg3, levels=c("workseg", "related content", 
  "unrelated content", "NONE")),
           Seg4 = factor(Seg4, levels=c("workseg", "related content", 
  "unrelated content", "NONE")))
  
  
  ##Plot##
  
  ggplot(as.data.frame(dRG.lode),
         aes(axis1 = Seg1, axis2 = Seg2, axis3 = Seg3, axis4 = Seg4)) +
    geom_alluvium(aes(fill = Seg4), width = 1/12) +
    guides(fill = FALSE) +
    geom_stratum(width = 1/12, fill = "black", color = "grey") +
    geom_label(stat = "stratum", label.strata = TRUE) +
    scale_x_discrete(limits = c("Seg1", "Seg2", "Seg3", "Seg4"), expand = 
  c(.05, .05, .05, .05)) +
    scale_fill_brewer(type = "qual", palette = "Set1") +
    ggtitle("Time Course, Segment by Segment")
  </code></pre>
  
  <p>...I have been able to produce the following plot:</p>
  
  <p><a href="https://i.stack.imgur.com/6iF0S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6iF0S.png" alt="...enter image description here"></a></p>
  
  <p>My main question:</p>
  
  <p>1) Is there a means by which to have the alluvial fill color not be consistent across an entire alluvial strand from start to finish, based on the Seg4 value, but INSTEAD to have the color change axis by axis, based upon the current axis value?  For instance, <strong>I'd like all strands with a strata value of "workseg" at a given axis to be blue between that axis and the previous axis.</strong>  Something akin to this seems possible based upon the vaccinations example at the bottom of <a href="https://cran.r-project.org/web/packages/ggalluvial/vignettes/ggalluvial.html" rel="nofollow noreferrer">this vignette</a> (see last plot above appendix). The fills in that example reflect the strata they each came from, axis to axis (e.g., all strands coming from a "Never" strata are teal, regardless of their value at the next axis).  I basically want to implement the inverse of this - that is, fill based on the strata of the <strong><em>next</em></strong> axis (e.g., all strands leading to a "workseg" strata are blue, regardless of where their value at the previous axis).</p>
  
  <p>An unrelated, secondary question:</p>
  
  <p>2) Is there any means by which to add annotation to alluvia?  That is, they axes contain strata labels based upon values in the data set, but is there a means by which to add labels or other annotative information to the strands themselves (beyond manually in post-production)?</p>