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 ac877a4

Browse filesBrowse files
committed
TST: Add test for large subscript
1 parent 17394ed commit ac877a4
Copy full SHA for ac877a4

File tree

Expand file treeCollapse file tree

3 files changed

+26
-11
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+26
-11
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+9-11Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,7 +2510,7 @@ def _update_title_position(self, renderer):
25102510
for title in titles:
25112511
x, y0 = title.get_position()
25122512
y = 1
2513-
# need to start agin in case of window resizing
2513+
# need to start again in case of window resizing
25142514
title.set_position((x, 1.0))
25152515
# need to check all our twins too...
25162516
axs = self._twinned_axes.get_siblings(self)
@@ -2528,19 +2528,17 @@ def _update_title_position(self, renderer):
25282528
# this happens for an empty bb
25292529
y = 1
25302530
bt = title.get_window_extent(renderer)
2531-
# need to do twice to get right for manual resizing
2532-
for nn in range(1):
2531+
dy = bt.ymin - top
2532+
if dy < 0:
2533+
y = self.transAxes.inverted().transform(
2534+
(0., top))[1]
2535+
title.set_position((x, y))
2536+
bt = title.get_window_extent(renderer)
25332537
dy = bt.ymin - top
25342538
if dy < 0:
25352539
y = self.transAxes.inverted().transform(
2536-
(0., top))[1]
2537-
title.set_position((x, y))
2538-
bt = title.get_window_extent(renderer)
2539-
dy = bt.ymin - top
2540-
if dy < 0:
2541-
y = self.transAxes.inverted().transform(
2542-
(0., top - dy))[1]
2543-
title.set_position((x, y))
2540+
(0., top - dy))[1]
2541+
title.set_position((x, y))
25442542
ymax = np.max((y, ymax))
25452543
for title in titles:
25462544
# now line up all the titles at the highest baseline.
Loading

‎lib/matplotlib/tests/test_text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_text.py
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,20 @@ def test_annotation_update():
510510

511511
assert not np.allclose(extent1.get_points(), extent2.get_points(),
512512
rtol=1e-6)
513+
514+
515+
@image_comparison(baseline_images=['large_subscript_title'],
516+
extensions=['png'], style='mpl20')
517+
def test_large_subscript_title():
518+
fig, axs = plt.subplots(1, 2, figsize=(9, 2.5), constrained_layout=True)
519+
ax = axs[0]
520+
ax.set_title('$\sum_{i} x_i$')
521+
ax.set_title('New way', loc='left')
522+
ax.set_xticklabels('')
523+
524+
ax = axs[1]
525+
tt = ax.set_title('$\sum_{i} x_i$')
526+
x, y = tt.get_position()
527+
tt.set_position((x, 1.01))
528+
ax.set_title('Old Way', loc='left')
529+
ax.set_xticklabels('')

0 commit comments

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