Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 497ffa8

Browse filesBrowse files
committed
Merge pull request #5700 from efiring/colorbar_tick_trim
BUG: handle colorbar ticks with boundaries and NoNorm; closes #5673
2 parents 81b8ced + 1616f67 commit 497ffa8
Copy full SHA for 497ffa8

File tree

Expand file treeCollapse file tree

4 files changed

+17
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+17
-1
lines changed
Open diff view settings
Collapse file

‎lib/matplotlib/colorbar.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def _ticker(self):
580580
else:
581581
b = self._boundaries[self._inside]
582582
locator = ticker.FixedLocator(b, nbins=10)
583-
if isinstance(self.norm, colors.NoNorm):
583+
if isinstance(self.norm, colors.NoNorm) and self.boundaries is None:
584584
intv = self._values[0], self._values[-1]
585585
else:
586586
intv = self.vmin, self.vmax
Collapse file
3 Bytes
  • Display the source diff
  • Display the rich diff
Loading
Collapse file
420 Bytes
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎lib/matplotlib/tests/test_colorbar.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colorbar.py
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,22 @@ def test_colorbar_closed_patch():
282282
extend='neither', values=values)
283283

284284

285+
@cleanup
286+
def test_colorbar_ticks():
287+
# test fix for #5673
288+
fig, ax = plt.subplots()
289+
x = np.arange(-3.0, 4.001)
290+
y = np.arange(-4.0, 3.001)
291+
X, Y = np.meshgrid(x, y)
292+
Z = X * Y
293+
clevs = np.array([-12, -5, 0, 5, 12], dtype=float)
294+
colors = ['r', 'g', 'b', 'c']
295+
cs = ax.contourf(X, Y, Z, clevs, colors=colors)
296+
cbar = fig.colorbar(cs, ax=ax, extend='neither',
297+
orientation='horizontal', ticks=clevs)
298+
assert len(cbar.ax.xaxis.get_ticklocs()) == len(clevs)
299+
300+
285301
if __name__ == '__main__':
286302
import nose
287303
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.