Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6b75057

Browse filesBrowse files
committed
FIX: layout for mixed descent multiline text objects
1 parent f3e03d2 commit 6b75057
Copy full SHA for 6b75057

File tree

Expand file treeCollapse file tree

1 file changed

+12
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-4
lines changed

‎lib/matplotlib/text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/text.py
+12-4Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,23 @@ 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+
# position at baseline
329+
thisy = -(h - d)
330+
else:
331+
# put baseline a good distance from bottom of previous line
332+
thisy -= max(offsety, (h - d) * self._linespacing)
328333
horizLayout[i] = thisx, thisy, w, h
329334
thisy -= d
330335
width = max(width, w)
331336
descent = d
332337

333-
ymin = horizLayout[-1][1]
334-
ymax = horizLayout[0][1] + horizLayout[0][3]
338+
# Bounding box definition:
339+
# by defeinition, ymax is 0
340+
ymax = 0
341+
# ymin is the baseline of the last line subtract the descent of the
342+
# last line.
343+
ymin = horizLayout[-1][1] - descent
335344
height = ymax - ymin
336345
xmax = xmin + width
337346

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

356364
# now rotate the bbox
357365
cornersRotated = M.transform(cornersHoriz)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.