-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Allow to both position_stack and position_nudge #161
Comments
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. Would this be possible as well? |
I guess it would need to be similar in principle to the code above, but using |
@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 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! |
Authored Michał Krassowski and posted as issue slowkow/ggrepel#161 I only added ggplot2:: to ensure it works even if 'ggplot2' is not attached.
I think ggpp is an OK place for |
Fine by me. AFK but my ORCID is https://orcid.org/0000-0002-9638-7785 |
@krassowski @slowkow Many thanks! I also implemented |
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:The text was updated successfully, but these errors were encountered: