8000 TST: test negative clevs BoundaryNorm · matplotlib/matplotlib@c71cf08 · GitHub
[go: up one dir, main page]

Skip to content

Commit c71cf08

Browse files
committed
TST: test negative clevs BoundaryNorm
1 parent 8a710b9 commit c71cf08

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/matplotlib/tests/test_colorbar.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,3 +873,24 @@ def test_proportional_colorbars():
873873
CS3 = axs[i, j].contourf(X, Y, Z, levels, cmap=cmap, norm=norm,
874874
extend=extends[i])
875875
fig.colorbar(CS3, spacing=spacings[j], ax=axs[i, j])
876+
877+
878+
def test_negative_boundarynorm():
879+
fig, ax = plt.subplots(figsize=(1, 3))
880+
cmap = plt.get_cmap("viridis")
881+
clevs = np.arange(-94, -85)
882+
norm = BoundaryNorm(clevs, cmap.N)
883+
cb = fig.colorbar(cm.ScalarMappable(cmap=cmap, norm=norm), cax=ax)
884+
np.testing.assert_allclose(cb.ax.get_ylim(), [clevs[0], clevs[-1]])
885+
np.testing.assert_allclose(cb.ax.get_yticks(), clevs)
886+
clevs = np.arange(85, 94)
887+
norm = BoundaryNorm(clevs, cmap.N)
888+
cb = fig.colorbar(cm.ScalarMappable(cmap=cmap, norm=norm), cax=ax)
889+
np.testing.assert_allclose(cb.ax.get_ylim(), [clevs[0], clevs[-1]])
890+
np.testing.assert_allclose(cb.ax.get_yticks(), clevs)
891+
892+
clevs = np.arange(-3, 3)
893+
norm = BoundaryNorm(clevs, cmap.N)
894+
cb = fig.colorbar(cm.ScalarMappable(cmap=cmap, norm=norm), cax=ax)
895+
np.testing.assert_allclose(cb.ax.get_ylim(), [clevs[0], clevs[-1]])
896+
np.testing.assert_allclose(cb.ax.get_yticks(), clevs)

0 commit comments

Comments
 (0)
0