BUG: handle colorbar ticks with boundaries and NoNorm; closes #5673 #5700

Merged
merged 2 commits into from Dec 20, 2015
@@ -580,7 +580,7 @@ def _ticker(self):
else:
b = self._boundaries[self._inside]
locator = ticker.FixedLocator(b, nbins=10)
- if isinstance(self.norm, colors.NoNorm):
+ if isinstance(self.norm, colors.NoNorm) and self.boundaries is None:
intv = self._values[0], self._values[-1]
else:
intv = self.vmin, self.vmax
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -282,6 +282,22 @@ def test_colorbar_closed_patch():
extend='neither', values=values)
+@cleanup
+def test_colorbar_ticks():
+ # test fix for #5673
+ fig, ax = plt.subplots()
+ x = np.arange(-3.0, 4.001)
+ y = np.arange(-4.0, 3.001)
+ X, Y = np.meshgrid(x, y)
+ Z = X * Y
+ clevs = np.array([-12, -5, 0, 5, 12], dtype=float)
+ colors = ['r', 'g', 'b', 'c']
+ cs = ax.contourf(X, Y, Z, clevs, colors=colors)
+ cbar = fig.colorbar(cs, ax=ax, extend='neither',
+ orientation='horizontal', ticks=clevs)
+ assert len(cbar.ax.xaxis.get_ticklocs()) == len(clevs)
+
+
if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)