Open krassowski opened 4 years ago
Thanks for sharing this! Very cool. I agree with you that we might want to distribute this in some package if there is interest.
I would be very much interested in such a feature. Specifically, I'd need a combination of position_dodge/position_jitter and position_nudge. Use case: I have geom_point that is dedged/jittered. I want to label the points but with an additional offset (nudge).
Would this be possible as well?
I guess it would need to be similar in principle to the code above, but using PositionJitterdodge
rather than PositionStack
.
@krassowski Hey Michał, if you're still interested, I would like to invite you to make a pull request with your new code. I might also add an example to show off this cool new feature.
Hey, I'm interested in this feature :) is a PR coming? :)
@krassowski @slowkow Are you both o.k. with me adding position_stack_and_nudge()
to package 'ggpp'? If yes, Michel, could you please send me your ORCID or directly add yourself as a contributor at https://github.com/aphalo/ggpp ?
I provisionally added the code to 'ggpp' and will do some testing, but it seems to work nicely. If you disagree, I will remove it.
Thanks!
I think ggpp is an OK place for position_stack_and_nudge()
.
Fine by me. AFK but my ORCID is https://orcid.org/0000-0002-9638-7785
@krassowski @slowkow Many thanks! I also implemented position_dodge_and_nudge()
in 'ggpp'.
Summary
I was trying to achieve something similar as in this question: Is there a possibility to combine position_stack and nudge_x in a stacked bar chart in ggplot2?, but with ggrepel. I think I succeeded.
Minimal code example
Intent
Having the following plot, I would like to move the names out of the bars and point to them with arrows:
Problem
Will raise:
Suggestions
Surprisingly, this turned out easy to implement with:
Where
position_stack_and_nudge()
is a combination ofggrepel::position_nudge2
andggplot::position_stack()
:This is my first attempt at modifying ggproto, and I am not confident in the quality of the code above, but it seems to work. Does ggproto allow multi-inheritance? This would have reduced the code much more!
My gut feeling is that it might be a bit specific use-case, so it might be just good enough to keep it in an issue, but if there is more users interested I could make it into a PR.
Version information
Here is the output from
sessionInfo()
in my R session: