Skip to content

Commit 05f1359

Browse files
committed
Tests have been added that check a figure created
with 1d color arrays against one with 2d color arrays. They should be identical if 2d arrays are read correctly.
1 parent ff891de commit 05f1359

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6513,3 +6513,22 @@ def test_multiplot_autoscale():
65136513
ax2.axhspan(-5, 5)
65146514
xlim = ax1.get_xlim()
65156515
assert np.allclose(xlim, [0.5, 4.5])
6516+
6517+
6518+
@check_figures_equal(extensions=["pdf"])
6519+
def test_2dcolor_plot(fig_test, fig_ref):
6520+
color = np.array([0.1, 0.2, 0.3])
6521+
# plot with 1D-color:
6522+
axs = fig_test.subplots(5)
6523+
axs[0].plot([1, 2], [1, 2], c=color.reshape((-1)))
6524+
axs[1].scatter([1, 2], [1, 2], c=color.reshape((-1)))
6525+
axs[2].step([1, 2], [1, 2], c=color.reshape((-1)))
6526+
axs[3].hist(np.arange(10), color=color.reshape((-1)))
6527+
axs[4].bar(np.arange(10), np.arange(10), color=color.reshape((-1)))
6528+
# plot with 2D-color:
6529+
axs = fig_ref.subplots(5)
6530+
axs[0].plot([1, 2], [1, 2], c=color.reshape((1, -1)))
6531+
axs[1].scatter([1, 2], [1, 2], c=color.reshape((1, -1)))
6532+
axs[2].step([1, 2], [1, 2], c=color.reshape((1, -1)))
6533+
axs[3].hist(np.arange(10), color=color.reshape((1, -1)))
6534+
axs[4].bar(np.arange(10), np.arange(10), color=color.reshape((1, -1)))

0 commit comments

Comments
 (0)