File tree Expand file tree Collapse file tree 3 files changed +25
-9
lines changed
Filter options
doc/api/next_api_changes/behavior Expand file tree Collapse file tree 3 files changed +25
-9
lines changed
Original file line number Diff line number Diff line change
1
+ TwoSlopeNorm now auto-expands to always have two slopes
2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
+ In the case where either ``vmin `` or ``vmax `` are not manually specified
4
+ to `~.TwoSlopeNorm `, and where the data it is scaling is all less than or
5
+ greater than the center point, the limits are now auto-expanded so there
6
+ are two symmetrically sized slopes either side of the center point.
7
+
8
+ Previously ``vmin `` and ``vmax `` were clipped at the center point, which
9
+ caused issues when displaying color bars.
10
+
11
+ This does not affect behaviour when ``vmin `` and ``vmax `` are manually
12
+ specified by the user.
Original file line number Diff line number Diff line change @@ -1432,13 +1432,17 @@ def vcenter(self, value):
1432
1432
1433
1433
def autoscale_None (self , A ):
1434
1434
"""
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].
1436
1440
"""
1437
1441
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 )
1442
1446
1443
1447
def __call__ (self , value , clip = None ):
1444
1448
"""
Original file line number Diff line number Diff line change @@ -665,16 +665,16 @@ def test_TwoSlopeNorm_scale():
665
665
def test_TwoSlopeNorm_scaleout_center ():
666
666
# test the vmin never goes above vcenter
667
667
norm = mcolors .TwoSlopeNorm (vcenter = 0 )
668
- norm ([1 , 2 , 3 , 5 ])
669
- assert norm .vmin == 0
668
+ norm ([0 , 1 , 2 , 3 , 5 ])
669
+ assert norm .vmin == - 5
670
670
assert norm .vmax == 5
671
671
672
672
673
673
def test_TwoSlopeNorm_scaleout_center_max ():
674
674
# test the vmax never goes below vcenter
675
675
norm = mcolors .TwoSlopeNorm (vcenter = 0 )
676
- norm ([- 1 , - 2 , - 3 , - 5 ])
677
- assert norm .vmax == 0
676
+ norm ([0 , - 1 , - 2 , - 3 , - 5 ])
677
+ assert norm .vmax == 5
678
678
assert norm .vmin == - 5
679
679
680
680
You can’t perform that action at this time.
0 commit comments