Skip to content

Commit 96ebbed

Browse files
committed
Adapt Line2D styles in tests so that it matches the PathPatch style
1 parent 71dc2d6 commit 96ebbed

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,28 +1822,31 @@ def test_stairs(fig_test, fig_ref):
18221822
test_axes[5].stairs(y, x, orientation='horizontal')
18231823
test_axes[5].semilogx()
18241824

1825+
# defaults of `PathPatch` to be used for all following Line2D
1826+
style = {'solid_joinstyle': 'miter', 'solid_capstyle': 'butt'}
1827+
18251828
ref_axes = fig_ref.subplots(3, 2).flatten()
1826-
ref_axes[0].plot(x, np.append(y, y[-1]), drawstyle='steps-post')
1827-
ref_axes[1].plot(np.append(y[0], y), x, drawstyle='steps-post')
1829+
ref_axes[0].plot(x, np.append(y, y[-1]), drawstyle='steps-post', **style)
1830+
ref_axes[1].plot(np.append(y[0], y), x, drawstyle='steps-post', **style)
18281831

1829-
ref_axes[2].plot(x, np.append(y, y[-1]), drawstyle='steps-post')
1830-
ref_axes[2].add_line(mlines.Line2D([x[0], x[0]], [0, y[0]]))
1831-
ref_axes[2].add_line(mlines.Line2D([x[-1], x[-1]], [0, y[-1]]))
1832+
ref_axes[2].plot(x, np.append(y, y[-1]), drawstyle='steps-post', **style)
1833+
ref_axes[2].add_line(mlines.Line2D([x[0], x[0]], [0, y[0]], **style))
1834+
ref_axes[2].add_line(mlines.Line2D([x[-1], x[-1]], [0, y[-1]], **style))
18321835
ref_axes[2].set_ylim(0, None)
18331836

1834-
ref_axes[3].plot(np.append(y[0], y), x, drawstyle='steps-post')
1835-
ref_axes[3].add_line(mlines.Line2D([0, y[0]], [x[0], x[0]]))
1836-
ref_axes[3].add_line(mlines.Line2D([0, y[-1]], [x[-1], x[-1]]))
1837+
ref_axes[3].plot(np.append(y[0], y), x, drawstyle='steps-post', **style)
1838+
ref_axes[3].add_line(mlines.Line2D([0, y[0]], [x[0], x[0]], **style))
1839+
ref_axes[3].add_line(mlines.Line2D([0, y[-1]], [x[-1], x[-1]], **style))
18371840
ref_axes[3].set_xlim(0, None)
18381841

1839-
ref_axes[4].plot(x, np.append(y, y[-1]), drawstyle='steps-post')
1840-
ref_axes[4].add_line(mlines.Line2D([x[0], x[0]], [0, y[0]]))
1841-
ref_axes[4].add_line(mlines.Line2D([x[-1], x[-1]], [0, y[-1]]))
1842+
ref_axes[4].plot(x, np.append(y, y[-1]), drawstyle='steps-post', **style)
1843+
ref_axes[4].add_line(mlines.Line2D([x[0], x[0]], [0, y[0]], **style))
1844+
ref_axes[4].add_line(mlines.Line2D([x[-1], x[-1]], [0, y[-1]], **style))
18421845
ref_axes[4].semilogy()
18431846

1844-
ref_axes[5].plot(np.append(y[0], y), x, drawstyle='steps-post')
1845-
ref_axes[5].add_line(mlines.Line2D([0, y[0]], [x[0], x[0]]))
1846-
ref_axes[5].add_line(mlines.Line2D([0, y[-1]], [x[-1], x[-1]]))
1847+
ref_axes[5].plot(np.append(y[0], y), x, drawstyle='steps-post', **style)
1848+
ref_axes[5].add_line(mlines.Line2D([0, y[0]], [x[0], x[0]], **style))
1849+
ref_axes[5].add_line(mlines.Line2D([0, y[-1]], [x[-1], x[-1]], **style))
18471850
ref_axes[5].semilogx()
18481851

18491852

@@ -1861,15 +1864,15 @@ def test_stairs_fill(fig_test, fig_ref):
18611864

18621865
# # Ref
18631866
ref_axes = fig_ref.subplots(2, 2).flatten()
1864-
ref_axes[0].fill_between(bins, np.append(h, h[-1]), step='post')
1867+
ref_axes[0].fill_between(bins, np.append(h, h[-1]), step='post', lw=0)
18651868
ref_axes[0].set_ylim(0, None)
1866-
ref_axes[1].fill_betweenx(bins, np.append(h, h[-1]), step='post')
1869+
ref_axes[1].fill_betweenx(bins, np.append(h, h[-1]), step='post', lw=0)
18671870
ref_axes[1].set_xlim(0, None)
18681871
ref_axes[2].fill_between(bins, np.append(h, h[-1]),
1869-
np.ones(len(h)+1)*bs, step='post')
1872+
np.ones(len(h)+1)*bs, step='post', lw=0)
18701873
ref_axes[2].set_ylim(bs, None)
18711874
ref_axes[3].fill_betweenx(bins, np.append(h, h[-1]),
1872-
np.ones(len(h)+1)*bs, step='post')
1875+
np.ones(len(h)+1)*bs, step='post', lw=0)
18731876
ref_axes[3].set_xlim(bs, None)
18741877

18751878

0 commit comments

Comments
 (0)