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

overlap_bbox_and_point returns 0 for points exactly in the centre of the bbox #49

Open
colinmorris opened this issue Apr 17, 2018 · 4 comments

Comments

@colinmorris
Copy link
Contributor

In the (rare) case where a point's x or y coordinate is exactly in the middle of the bbox, the sign of cx -xp or cy-yp will be 0, so overlap_bbox_and_point will return a displacement of 0 along that axis, whereas it should return either xp - bbox.xmax or xp - bbox.xmin (which will have the same absolute value but different signs).

@Phlya
Copy link
Owner

Phlya commented Apr 17, 2018

Right... Would you agree that simply having a positive sign in that case is a good solution?
I guess this actually happens with the (default) settings ha='center', va='center', if autoalignment is off? Need to check.

@colinmorris
Copy link
Contributor Author

By having a positive sign, you mean moving the text right/down? Sure, though I don't really have an opinion on that vs. left/up.

@schlegelp
Copy link

I'm having a related issue: When texts' starting positions are the same, they will never be moved apart.

One conceivable option would be to check for text occupying the same position at the start and apply some random jitter to separate them before starting the force displacement process?

@Phlya
Copy link
Owner

Phlya commented Dec 18, 2018

Yes, this is true, for now you can easily add random shift manually, could be an option in adjust_text itself too. If you would like to submit a PR I'll gladly merge it.

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

No branches or pull requests

3 participants