8000 Replaced image comparison test for titletwiny · matplotlib/matplotlib@c484312 · GitHub
[go: up one dir, main page]

Skip to content

Commit c484312

Browse files
committed
Replaced image comparison test for titletwiny
1 parent 1ad7eb0 commit c484312

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed
Binary file not shown.

lib/matplotlib/tests/test_axes.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6014,18 +6014,19 @@ def test_axisbelow():
60146014
ax.set_axisbelow(setting)
60156015

60166016

6017-
@image_comparison(['titletwiny.png'], style='mpl20')
60186017
def test_titletwiny():
6019-
# Remove this line when this test image is regenerated.
6020-
plt.rcParams['text.kerning_factor'] = 6
6021-
6022-
# Test that title is put above xlabel if xlabel at top
6023-
fig, ax = plt.subplots()
6024-
fig.subplots_adjust(top=0.8)
6018+
plt.style.use('mpl20')
6019+
fig, ax = plt.subplots(dpi=72)
60256020
ax2 = ax.twiny()
6026-
ax.set_xlabel('Xlabel')
6027-
ax2.set_xlabel('Xlabel2')
6028-
ax.set_title('Title')
6021+
xlabel2 = ax2.set_xlabel('Xlabel2')
6022+
title = ax.set_title('Title')
6023+
fig.canvas.draw()
6024+
renderer = fig.canvas.get_renderer()
6025+
# ------- Test that title is put above Xlabel2 (Xlabel2 at top) ----------
6026+
bbox_y0_title = title.get_window_extent(renderer).y0 # bottom of title
6027+
bbox_y1_xlabel2 = xlabel2.get_window_extent(renderer).y1 # top of xlabel2
6028+
y_diff = bbox_y0_title - bbox_y1_xlabel2
6029+
assert np.isclose(y_diff, 3)
60296030

60306031

60316032
def test_titlesetpos():

0 commit comments

Comments
 (0)
0