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

Skip to content

Commit 80019a8

Browse files
committed
added suggested protection against changes to vmin
1 parent 2f9fd02 commit 80019a8

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/matplotlib/colors.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ def __init__(self, vcenter=0, vmax=None, clip=False):
12871287
>>> norm = mcolors.SymNorm(vmax=4.0)
12881288
>>> data = [-2., 0., 4.]
12891289
>>> norm(data)
1290-
array([[0.25, 0.5 , 1. ])
1290+
array([0.25, 0.5 , 1. ])
12911291
"""
12921292

12931293
self._vcenter = vcenter
@@ -1329,6 +1329,12 @@ def vcenter(self, vcenter):
13291329
self.vmax-self._vcenter)
13301330
self.vmin = 2*self._vcenter - self.vmax
13311331

1332+
def __call__(self, value, clip=None):
1333+
if self.vmax is not None:
1334+
# enforce symmetry, undo changes to vmin
1335+
self.vmin = 2*self._vcenter - self.vmax
1336+
return super().__call__(value, clip=clip)
1337+
13321338

13331339
def _make_norm_from_scale(scale_cls, base_norm_cls=None, *, init=None):
13341340
"""

0 commit comments

Comments
 (0)