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

Skip to content

Commit 585cf56

Browse files
committed
Ensure TwoSlopNorm always has two slopes
1 parent 85d7bb3 commit 585cf56

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/matplotlib/colors.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,13 +1432,17 @@ def vcenter(self, value):
14321432

14331433
def autoscale_None(self, A):
14341434
"""
1435-
Get vmin and vmax, and then clip at vcenter
1435+
Get vmin and vmax.
1436+
1437+
If vcenter isn't in the range [vmin, vmax], either vmin or vmax
1438+
is expanded so that vcenter lies in the middle of the modified range
1439+
[vmin, vmax].
14361440
"""
14371441
super().autoscale_None(A)
1438-
if self.vmin > self.vcenter:
1439-
self.vmin = self.vcenter
1440-
if self.vmax < self.vcenter:
1441-
self.vmax = self.vcenter
1442+
if self.vmin >= self.vcenter:
1443+
self.vmin = self.vcenter - (self.vmax - self.vcenter)
1444+
if self.vmax <= self.vcenter:
1445+
self.vmax = self.vcenter + (self.vcenter - self.vmin)
14421446

14431447
def __call__(self, value, clip=None):
14441448
"""

0 commit comments

Comments
 (0)