Closed statsccpr closed 6 years ago
I don't think ggplot2 has the coordinates - they're computed by grid, and hence this would be more appropriate in an extension package.
These values are all calculated at draw time so they cannot even be accessed in grid. ggforce has a couple of geoms, such as arcs, beziers, and splines (and straight lines) that calculates the points directly and can thus be accessed...
I see, so it seems like ggplot passes its arguments down the internal pipeline to grid::curve then @thomasp85 explanation would answer the questions 1) and 2) posed in the original post with "you can not"
At first, i posted in a related topic that's been closed https://github.com/tidyverse/ggplot2/issues/2280#issuecomment-351476755 The above thread would be the use case of this feature request here.
Although @hadley 's response to the originating closed feature request said it's better as an extension package. I think the fundamental root feature that would allow for all of this to work is the feature request in this independent thread here, which seems to be a 'vanilla' ggplot output.
If a user has access to the intermediate coordinates that ggplot2 uses to display
users can add additional plot elements based on the intermediate coordinates
In the original use case, the intermediate coordinates can be used to place custom arrowhead locations other than the enforced 'end' of the segment, say placing the arrowheads in the 'midpoint' of the segment
I dug around and see that
geom_curve()
usesgrid::curveGrob()
but i can't quite figure out 1) how
curveGrob()
returns the coordinate values. 2) how ggplot2 stores or returns these intermediate coordinate values, output from 1The big picture would be, once the curveGrob() coordinates are identified, the ggplot2 user could extract that from
Then use it like