Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8df6787

Browse files
committed
FIX: layout for mixed descent multiline text objects
1 parent f3e03d2 commit 8df6787

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/text.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,17 @@ def _get_layout(self, renderer):
324324
whs[i] = w, h
325325

326326
baseline = (h - d) - thisy
327-
thisy -= max(offsety, (h - d) * self._linespacing)
327+
if i > 0:
328+
thisy -= max(offsety, (h - d) * self._linespacing)
329+
else:
330+
thisy = -(h - d)
328331
horizLayout[i] = thisx, thisy, w, h
329332
thisy -= d
330333
width = max(width, w)
331334
descent = d
332335

333-
ymin = horizLayout[-1][1]
334-
ymax = horizLayout[0][1] + horizLayout[0][3]
336+
ymin = horizLayout[-1][1] - d
337+
ymax = 0
335338
height = ymax - ymin
336339
xmax = xmin + width
337340

@@ -351,7 +354,6 @@ def _get_layout(self, renderer):
351354
# the corners of the unrotated bounding box
352355
cornersHoriz = np.array(
353356
[(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)], float)
354-
cornersHoriz[:, 1] -= descent
355357

356358
# now rotate the bbox
357359
cornersRotated = M.transform(cornersHoriz)

0 commit comments

Comments
 (0)