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 e43763a

Browse filesBrowse files
committed
FIX: let extends work for PowerNorm
1 parent d80c9fb commit e43763a
Copy full SHA for e43763a

File tree

Expand file treeCollapse file tree

2 files changed

+12
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-3
lines changed

‎lib/matplotlib/colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,9 @@ def _process_values(self, b=None):
802802

803803
b = self.norm.inverse(self._uniform_y(self.cmap.N + 1))
804804

805-
if isinstance(self.norm, colors.LogNorm):
806-
# If using a lognorm, ensure extensions don't go negative
805+
if isinstance(self.norm, (colors.PowerNorm, colors.LogNorm)):
806+
# If using a lognorm or powernorm, ensure extensions don't
807+
# go negative
807808
if self._extend_lower():
808809
b[0] = 0.9 * b[0]
809810
if self._extend_upper():

‎lib/matplotlib/tests/test_colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colorbar.py
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from matplotlib import rc_context
55
from matplotlib.testing.decorators import image_comparison
66
import matplotlib.pyplot as plt
7-
from matplotlib.colors import BoundaryNorm, LogNorm
7+
from matplotlib.colors import BoundaryNorm, LogNorm, PowerNorm
88
from matplotlib.cm import get_cmap
99
from matplotlib.colorbar import ColorbarBase
1010

@@ -348,6 +348,14 @@ def test_colorbar_lognorm_extension():
348348
assert cb._values[0] >= 0.0
349349

350350

351+
def test_colorbar_powernorm_extension():
352+
# Test that colorbar with powernorm is extended correctly
353+
f, ax = plt.subplots()
354+
cb = ColorbarBase(ax, norm=PowerNorm(gamma=0.5, vmin=0.0, vmax=1.0),
355+
orientation='vertical', extend='both')
356+
assert cb._values[0] >= 0.0
357+
358+
351359
def test_colorbar_axes_kw():
352360
# test fix for #8493: This does only test, that axes-related keywords pass
353361
# and do not raise an exception.

0 commit comments

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