adjustText icon indicating copy to clipboard operation
adjustText copied to clipboard

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

Open colinmorris opened this issue 7 years ago • 4 comments

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).

colinmorris avatar Apr 17 '18 22:04 colinmorris

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.

Phlya avatar Apr 17 '18 22:04 Phlya

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.

colinmorris avatar Apr 18 '18 00:04 colinmorris

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?

schlegelp avatar Dec 18 '18 17:12 schlegelp

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.

Phlya avatar Dec 18 '18 18:12 Phlya