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 2ab0e05

Browse filesBrowse files
author
Nora Moseman
committed
do not call plot(), set explicit positive y_lim for subplots, fix formatting
1 parent 40f7848 commit 2ab0e05
Copy full SHA for 2ab0e05

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+6
-11
lines changed

‎lib/matplotlib/tests/test_constrainedlayout.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_constrainedlayout.py
+6-11Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -529,34 +529,29 @@ def test_align_labels():
529529
three unevenly sized subplots, one of whose y tick labels include
530530
negative numbers, drives the non-negative subplots' y labels off
531531
the edge of the plot
532-
533532
"""
534-
535-
data = [0, 1]
536-
537533
fig, (ax3, ax1, ax2) = plt.subplots(3, 1, constrained_layout=True,
538534
figsize=(6.4, 8),
539535
gridspec_kw={"height_ratios": (1, 1,
540536
0.7)})
541537

542-
ax1.plot(data, data)
538+
ax1.set_ylim(0, 1)
543539
ax1.set_ylabel("Label")
544540

545-
ax2.plot(data, data)
546541
ax2.set_ylim(-1.5, 1.5)
547542
ax2.set_ylabel("Label")
548543

549-
ax3.plot(data, data)
544+
ax3.set_ylim(0, 1)
550545
ax3.set_ylabel("Label")
551546

552547
fig.align_ylabels(axs=(ax3, ax1, ax2))
553548

554549
fig.canvas.draw()
555-
after_align = (ax1.yaxis.label.get_window_extent(),
550+
after_align = [ax1.yaxis.label.get_window_extent(),
556551
ax2.yaxis.label.get_window_extent(),
557-
ax3.yaxis.label.get_window_extent())
558-
#ensure labels are approximately aligned
552+
ax3.yaxis.label.get_window_extent()]
553+
# ensure labels are approximately aligned
559554
np.testing.assert_allclose([after_align[0].x0, after_align[2].x0],
560555
after_align[1].x0, rtol=0, atol=1e-05)
561-
#ensure labels do not go off the edge
556+
# ensure labels do not go off the edge
562557
assert after_align[0].x0 >= 1

0 commit comments

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