ggrepel
ggrepel copied to clipboard
Use of repel algorithm in other packages?
I am developing a ggplot2
extension (gglyph
) and would like to use the repel algorithm from ggrepel
. I am able to get desired results even though I am trying to repel polygon grobs instead of text grobs.
Are you still considering exporting ggrepel:::repel_boxes2()
? or can I copy the necessary code in my package with attribution as in the case of metacoder and as discussed in #88 ?
Thanks for the question! Your package looks interesting, and I'm impressed that you're successfully using the repel_boxes2()
function. Your example helps me to understand why this function might be useful for other developers.
The license gives permission for any developer to copy code from ggrepel. There's no need to ask me for permission.
Feel free to decide for yourself whether you'd like to copy the code and modify it, or if you'd like to add ggrepel as a dependency.
If you want to avoid waiting for me, then the fastest way forward is to copy the code. This approach also gives you ultimate freedom to customize absolutely everything exactly as you want for your particular application.
If you prefer to add ggrepel as a dependency, then this might take some time. I would need to upload a new release of ggrepel on CRAN where the repel_boxes2()
function is exported. I don't want to cause any delays for you, but I don't know if I can upload a new release to CRAN any time soon. Updates for ggrepel can take some time, because I want to be sure that I'm not breaking anything or introducing new bugs. It can be very time-consuming to try to make changes safely.
If you think that exporting repel_boxes2()
is a good idea, then you might consider helping with ggrepel development by creating a pull request with these changes:
- export the
repel_boxes2()
function - create a new documentation page for
repel_boxes2()
- rename
repel_boxes2()
to something more reasonable, mayberepel_boxes()
- on the documentation page, share at least one short code snippet showing how developers like you can use this exported function
- add an item to NEWS.md about this change
- add yourself to the authors in DESCRIPTION
Just a follow-up on this:
I am also interested in having repel_boxes2
exported in ggrepel, so that other functions/packages can use it. Specifically, I'm using a lot of lattice
plots but there is no function that works as well as ggrepel
in repelling labels.
What I did now was to copy the C++ function and add it to my own package latticetools, from where it is exported. That means in this package, repel_boxes
can be called directly. But the main usage is to call it from within a lattice panel function, panel.repellabels
(the counter part of a ggplot geom). I have added you @slowkow as a co-author for the package, and in the long run might give your suggestion a try to export it directly in ggrepel, as you mentioned above.
@m-jahn Thank you for the kind note! I think copying the code is a fine solution, and gives you freedom to change everything. 👍
Great! That said, are you @slowkow as the ggrepel
maintainer still interested in having repel_boxes(2)
exported according to your suggestion in your previous comment? Since I did it now for my own package, it would be easy to make a commit + PR for ggrepel
too, and that would settle these and future requests for a standalone box repel function.
@m-jahn I would be very happy to merge a PR that exports a usable function, but I don't have time right now to write the PR by myself or to test it extensively.
If you decide to do this, please do add yourself as an author to the DESCRIPTION file, and add a new item in the NEWS.md file to summarize the change.
I think the ideal PR might also include a new documentation page that shows code examples for how developers might use the exported function.
Thanks @slowkow, I think I will give it a try.
As an FYI, there is this package that may be of interest to you @m-jahn and @aravind-j https://github.com/hms-dbmi/repel