adjustText
adjustText copied to clipboard
overlap_bbox_and_point returns 0 for points exactly in the centre of the bbox
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).
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.
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.
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?
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.