We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 37ff5a5 commit 2d41664Copy full SHA for 2d41664
2 files changed
lib/matplotlib/colors.py
@@ -225,6 +225,7 @@ def rgb2hex(rgb):
225
a = '#%02x%02x%02x' % tuple([int(np.round(val * 255)) for val in rgb[:3]])
226
return a
227
228
+
229
hexColorPattern = re.compile("\A#[a-fA-F0-9]{6}\Z")
230
231
@@ -1043,6 +1044,14 @@ def inverse(self, value):
1043
1044
return inverted[0]
1045
1046
1047
+class SymmetricalNorm(Normalize):
1048
+ def __init__(self, vmin=None, vmax=None, clip=False):
1049
+ limit = np.max(np.abs([vmin, vmax]))
1050
+ self.vmin = limit * -1
1051
+ self.vmax = limit
1052
+ self.clip = clip
1053
1054
1055
class LogNorm(Normalize):
1056
"""
1057
Normalize a given value to the 0-1 range on a log scale
lib/matplotlib/tests/test_colors.py
@@ -101,13 +101,21 @@ def setup(self):
101
self.vals = np.array([-1, -0.5, 0.0, 1.0, 2.0, 3.0, 4.0])
102
self.expected = np.array([0.0, 0.25, 0.5, 0.625, 0.75, 0.875, 1.0])
103
104
105
class test_OffsetNorm_Even(_base_NormMixin):
106
def setup(self):
107
self.norm = mcolors.OffsetNorm(vmin=-2, vcenter=0, vmax=5)
108
self.vals = np.array([-2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
109
self.expected = np.array([0.0, 0.25, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
110
111
112
+class test_SymmetricalNorm(_base_NormMixin):
113
+ def setup(self):
114
+ self.norm = mcolors.SymmetricalNorm(vmin=-2, vmax=4)
115
+ self.vals = np.array([-2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0])
116
+ self.expected = np.array([0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0])
117
118
119
def test_SymLogNorm():
120
121
Test SymLogNorm behavior
0 commit comments