8000 Fix Issue #2060: Text bbox alignment · matplotlib/matplotlib@325a7c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 325a7c8

Browse files
committed
Fix Issue #2060: Text bbox alignment
1 parent e2bf78e commit 325a7c8

20 files changed

+899
-805
lines changed

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
235235
w, h, d = self.get_text_width_height_descent(s, prop, ismath)
236236
xd = d * np.sin(np.deg2rad(angle))
237237
yd = d * np.cos(np.deg2rad(angle))
238-
x = np.round(x - xd)
238+
x = np.round(x + xd)
239239
y = np.round(y + yd)
240240

241241
self._renderer.draw_text_image(Z, x, y, angle, gc)

lib/matplotlib/offsetbox.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,13 +718,10 @@ def get_extent(self, renderer):
718718
_, h_, d_ = renderer.get_text_width_height_descent(
719719
"lp", self._text._fontproperties, ismath=False)
720720

721-
bbox, info = self._text._get_layout(renderer)
721+
bbox, info, d = self._text._get_layout(renderer)
722722
w, h = bbox.width, bbox.height
723723

724724
line = info[-1][0] # last line
725-
_, hh, dd = renderer.get_text_width_height_descent(
726-
line, self._text._fontproperties, ismath=ismath)
727-
d = dd # the baseline of the last line
728725

729726
self._baseline_transform.clear()
730727

Binary file not shown.
Loading

lib/matplotlib/tests/baseline_images/test_axes/markevery.svg

Lines changed: 263 additions & 263 deletions
Loading
Binary file not shown.
Loading

lib/matplotlib/tests/baseline_images/test_axes/markevery_line.svg

Lines changed: 275 additions & 275 deletions
Loading
Binary file not shown.
Binary file not shown.
Loading

0 commit comments

Comments
 (0)
0