MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_negative_boundarynorm

Function test_negative_boundarynorm

lib/matplotlib/tests/test_colorbar.py:1056–1082  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1054
1055
1056def test_negative_boundarynorm():
1057 fig, ax = plt.subplots(figsize=(1, 3))
1058 cmap = mpl.colormaps["viridis"]
1059
1060 clevs = np.arange(-94, -85)
1061 norm = BoundaryNorm(clevs, cmap.N)
1062 cb = fig.colorbar(cm.ScalarMappable(cmap=cmap, norm=norm), cax=ax)
1063 np.testing.assert_allclose(cb.ax.get_ylim(), [clevs[0], clevs[-1]])
1064 np.testing.assert_allclose(cb.ax.get_yticks(), clevs)
1065
1066 clevs = np.arange(85, 94)
1067 norm = BoundaryNorm(clevs, cmap.N)
1068 cb = fig.colorbar(cm.ScalarMappable(cmap=cmap, norm=norm), cax=ax)
1069 np.testing.assert_allclose(cb.ax.get_ylim(), [clevs[0], clevs[-1]])
1070 np.testing.assert_allclose(cb.ax.get_yticks(), clevs)
1071
1072 clevs = np.arange(-3, 3)
1073 norm = BoundaryNorm(clevs, cmap.N)
1074 cb = fig.colorbar(cm.ScalarMappable(cmap=cmap, norm=norm), cax=ax)
1075 np.testing.assert_allclose(cb.ax.get_ylim(), [clevs[0], clevs[-1]])
1076 np.testing.assert_allclose(cb.ax.get_yticks(), clevs)
1077
1078 clevs = np.arange(-8, 1)
1079 norm = BoundaryNorm(clevs, cmap.N)
1080 cb = fig.colorbar(cm.ScalarMappable(cmap=cmap, norm=norm), cax=ax)
1081 np.testing.assert_allclose(cb.ax.get_ylim(), [clevs[0], clevs[-1]])
1082 np.testing.assert_allclose(cb.ax.get_yticks(), clevs)
1083
1084
1085def test_centerednorm():

Callers

nothing calls this directly

Calls 4

BoundaryNormClass · 0.90
subplotsMethod · 0.45
colorbarMethod · 0.45
get_ylimMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…