Skip to content
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

Avoid labels intersecting segments #34

Closed
ghost opened this issue Apr 13, 2016 · 2 comments
Closed

Avoid labels intersecting segments #34

ghost opened this issue Apr 13, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 13, 2016

Would it be possible to avoid segments intersecting other labels as in this example:

image

It seems you are using a force directed layout, which IIRC does not really concern itself with the segments but only the nodes. One solution might be to ramp up the force when intersections are detected?

Detecting intersections for all labels may be just way too computationally expensive, so feel free to close issue if not feasible! (Thanks for fantastic package!)

@slowkow
Copy link
Owner

slowkow commented Apr 14, 2016

Thanks for opening this issue and including a figure that shows the problem.

Indeed, the algorithm is using repulsive forces to push labels away from each other, and to push labels away from the labeled points. I might suggest using one of the existing functions in my code to compute the intersection between a rectangle and a line, and then repelling the rectangle away from this intersection point. There may be some unexpected consequences, but I think it's worth a try.

I would be very happy to review a pull request that implements this feature. If you decide to do it, please include test cases that show off the new behavior.

@slowkow
Copy link
Owner

slowkow commented Nov 19, 2017

@erikor Could I please ask you to try the latest ggrepel 0.7.1 and let me know if it works better for cases where line segments are intersecting? @AliciaSchep implemented some new code and I have a feeling you might like the new behavior.

devtools::install_github("slowkow/ggrepel@0.7.1")

Hope it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant