-
Notifications
You must be signed in to change notification settings - Fork 34
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
Feature request: arrow-shaped flows? #67
Comments
Hi @ccotroneo — i'm glad the package appeals, and thanks for the suggestion! Please pardon the long-winded response. I can see the appeal of this feature, given that the typical alluvial plot is only directional insofar as the horizontal axis has an obvious meaning (like a unit of time or the stage of a process). So arrows would help indicate directionality in cases where the axis itself doesn't. why i'm not sureI'm resistant in part because i have trouble coming up with a natural use case, in which arrows would add meaning to the plot that cannot be added by the axes. Do you have a specific one in mind? (One possibility is the vaccination survey data installed with ggalluvial, which includes data from three surveys conducted at different times but does not include their dates.) My guiding principle here is that the statistical graphic should be completely determined by the data. For example, a natural use case for arrows is a network model of trade; visualized as a graph, two nodes (representing, say, countries) may have two, one, or no arrows connecting them, depending on which imports from the other. Another reason is that i've tried to distinguish alluvial plots from the much larger species of Sankey diagrams. These usually represent directed flows and often have much freer forms, which may render horizontal and vertical axes meaningless and make arrows more appropriate and essential (and traditional). I don't know of any such ggplot2 extensions, unfortunately. how it might workAn important question to ask about this feature would be how the directions of arrows are determined. Presumably one wouldn't just want them to always point rightward (or, more generally, in the direction of the This might be done using an additional aesthetic variable, at least for Flows, using how it might lookFinally, it might be tricky to represent the heads and tails of arrows of flows in a way that does not cause graphical elements to overlap. For example, here's a very basic idea of how a flow could look directed: library(grid)
grid.newpage()
# open 2-plot layout
pushViewport(viewport(width = 1, x = 0, just = "left",
layout = grid.layout(2, 1, respect = TRUE)))
# standard flow
pushViewport(viewport(layout.pos.row = 1, layout.pos.col = 1))
grid.xspline(
x = c(0, .25, .75, 1, 1, .75, .25, 0),
y = c(0, 0, .8, .8, 1, 1, .2, .2),
shape = c(0, 1, 1, 0, 0, 1, 1, 0),
open = FALSE, gp = gpar(fill = "lightgrey")
)
popViewport()
# directed flow
pushViewport(viewport(layout.pos.row = 2, layout.pos.col = 1))
grid.xspline(
x = c(0, .1, .275, .725, .9, 1, .9, .725, .275, .1, 0, .1),
y = c(0, 0, 0, .8, .8, .9, 1, 1, .2, .2, .2, .1),
shape = c(0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0),
open = FALSE, gp = gpar(fill = "lightgrey")
)
popViewport()
# close 2-plot layout
popViewport() Created on 2020-10-23 by the reprex package (v0.3.0) The potential problem with this graphical element is that, in order to prevent the arrow head from overlapping with the lode (rectangle) incident to it (which could cause miscoloration among other problems), the two ends of the basic ribbon are contracted to make room for the head and tail to protrude outward. This isn't a huge problem necessarily, but it would make an alluvial plot somewhat more crowded. what to do nextIf you (or anyone reading this) have suggestions on how to better resolve some of these issues, i'd be interested to hear them! At the moment, though, i don't feel ready to implement such a feature myself. |
Hi Cory,
thanks a lot for this package, it really looks great! Just a quick question: is there already a way or will there be a way to shape the different flow lines as arrows? :)
The text was updated successfully, but these errors were encountered: