Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ff2086

Browse files
committed
MNT: Pending-deprecate setting colormap extremes
Per #29141 we have the long-term plan to make colormaps immutable. As a result, the in-place modifications have to be removed. We take this particularly slow with at least two minor releases of pending deprecation and two further releases of actual deprecations. As it's quite a common concept and migrating away will take time.
1 parent 352b419 commit 0ff2086

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/matplotlib/colors.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,10 @@ def get_bad(self):
875875
self._init()
876876
return np.array(self._lut[self._i_bad])
877877

878+
@_api.deprecated(
879+
"3.11",
880+
pending=True,
881+
alternative="cmap.with_extremes(bad=...) or Colormap(bad=...)")
878882
def set_bad(self, color='k', alpha=None):
879883
"""Set the color for masked values."""
880884
self._rgba_bad = to_rgba(color, alpha)
@@ -887,6 +891,10 @@ def get_under(self):
887891
self._init()
888892
return np.array(self._lut[self._i_under])
889893

894+
@_api.deprecated(
895+
"3.11",
896+
pending=True,
897+
alternative="cmap.with_extremes(under=...) or Colormap(under=...)")
890898
def set_under(self, color='k', alpha=None):
891899
"""Set the color for low out-of-range values."""
892900
self._rgba_under = to_rgba(color, alpha)
@@ -899,12 +907,21 @@ def get_over(self):
899907
self._init()
900908
return np.array(self._lut[self._i_over])
901909

910+
@_api.deprecated(
911+
"3.11",
912+
pending=True,
913+
alternative="cmap.with_extremes(over=...) or Colormap(over=...)")
902914
def set_over(self, color='k', alpha=None):
903915
"""Set the color for high out-of-range values."""
904916
self._rgba_over = to_rgba(color, alpha)
905917
if self._isinit:
906918
self._set_extremes()
907919

920+
@_api.deprecated(
921+
"3.11",
922+
pending=True,
923+
alternative="cmap.with_extremes(bad=..., under=..., over=...) or "
924+
"Colormap(bad=..., under=..., over=...)")
908925
def set_extremes(self, *, bad=None, under=None, over=None):
909926
"""
910927
Set the colors for masked (*bad*) values and, when ``norm.clip =

0 commit comments

Comments
 (0)