Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,16 @@ def _get_dist_to_box(self, rotation, x0, y0, figure_box):
Return the distance from the given points to the boundaries of a
rotated box, in pixels.
"""
rotation %= 360
if rotation == 0:
return figure_box.x1 - x0
if rotation == 90:
return figure_box.y1 - y0
if rotation == 180:
return x0 - figure_box.x0
if rotation == 270:
return y0 - figure_box.y0

if rotation > 270:
quad = rotation - 270
h1 = (y0 - figure_box.y0) / math.cos(math.radians(quad))
Expand Down
Loading