8000 FIX: fix equal spaced · matplotlib/matplotlib@6423cc5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6423cc5

Browse files
committed
FIX: fix equal spaced
1 parent c71cf08 commit 6423cc5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/matplotlib/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ def _mesh(self):
11501150

11511151
def _forward_boundaries(self, x):
11521152
b = self._boundaries
1153-
y = np.interp(x, b, np.linspace(0, np.abs(b[-1]), len(b)))
1153+
y = np.interp(x, b, np.linspace(0, b[-1]-b[0], len(b)))
11541154
eps = (b[-1] - b[0]) * 1e-6
11551155
y[x < b[0]-eps] = -1
11561156
y[x > b[-1]+eps] = 2

lib/matplotlib/tests/test_colorbar.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,3 +894,10 @@ def test_negative_boundarynorm():
894894
cb = fig.colorbar(cm.ScalarMappable(cmap=cmap, norm=norm), cax=ax)
895895
np.testing.assert_allclose(cb.ax.get_ylim(), [clevs[0], clevs[-1]])
896896
np.testing.assert_allclose(cb.ax.get_yticks(), clevs)
897+
898+
clevs = np.arange(-8, 1)
899+
norm = BoundaryNorm(clevs, cmap.N)
900+
cb = fig.colorbar(cm.ScalarMappable(cmap=cmap, norm=norm), cax=ax)
901+
np.testing.assert_allclose(cb.ax.get_ylim(), [clevs[0], clevs[-1]])
902+
np.testing.assert_allclose(cb.ax.get_yticks(), clevs)
903+

0 commit comments

Comments
 (0)
0