Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a6f13e9

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. + Rebase with master + Change .reshape((-1)) to .reshape(-1)
1 parent b1b0006 commit a6f13e9

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
@@ -6590,3 +6590,22 @@ def test_sharing_does_not_link_positions():
65906590
init_pos = ax1.get_position()
65916591
fig.subplots_adjust(left=0)
65926592
assert (ax1.get_position().get_points() == init_pos.get_points()).all()
6593+
6594+
6595+
@check_figures_equal(extensions=["pdf"])
6596+
def test_2dcolor_plot(fig_test, fig_ref):
6597+
color = np.array([0.1, 0.2, 0.3])
6598+
# plot with 1D-color:
6599+
axs = fig_test.subplots(5)
6600+
axs[0].plot([1, 2], [1, 2], c=color.reshape(-1))
6601+
axs[1].scatter([1, 2], [1, 2], c=color.reshape(-1))
6602+
axs[2].step([1, 2], [1, 2], c=color.reshape(-1))
6603+
axs[3].hist(np.arange(10), color=color.reshape(-1))
6604+
axs[4].bar(np.arange(10), np.arange(10), color=color.reshape(-1))
6605+
# plot with 2D-color:
6606+
axs = fig_ref.subplots(5)
6607+
axs[0].plot([1, 2], [1, 2], c=color.reshape((1, -1)))
6608+
axs[1].scatter([1, 2], [1, 2], c=color.reshape((1, -1)))
6609+
axs[2].step([1, 2], [1, 2], c=color.reshape((1, -1)))
6610+
axs[3].hist(np.arange(10), color=color.reshape((1, -1)))
6611+
axs[4].bar(np.arange(10), np.arange(10), color=color.reshape((1, -1)))

0 commit comments

Comments
 (0)