MCPcopy Create free account
hub / github.com/bab2min/tomotopy / ExpNormalize

Class ExpNormalize

examples/gdmr_plot.py:14–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12import matplotlib.colors as clr
13
14class ExpNormalize(clr.Normalize):
15 def __init__(self, scale):
16 super().__init__()
17 self.scale = scale
18
19 def __call__(self, value, clip=None):
20 if clip is None:
21 clip = self.clip
22
23 result, is_scalar = self.process_value(value)
24
25 self.autoscale_None(result)
26 (vmin,), _ = self.process_value(self.vmin)
27 (vmax,), _ = self.process_value(self.vmax)
28 if vmin == vmax:
29 result.fill(0)
30 elif vmin > vmax:
31 raise ValueError("minvalue must be less than or equal to maxvalue")
32 else:
33 if clip:
34 mask = np.ma.getmask(result)
35 result = np.ma.array(np.clip(result.filled(vmax), vmin, vmax),
36 mask=mask)
37 resdat = result.data
38 resdat = 1 - np.exp(-2 * resdat / self.scale)
39 result = np.ma.array(resdat, mask=result.mask, copy=False)
40 if is_scalar:
41 result = result[0]
42 return result
43
44heat = clr.LinearSegmentedColormap.from_list('heat',
45 [(0, 0, 0), (0, 0, 1), (0, 1, 1), (0, 1, 0), (1, 1, 0), (1, 0, 0), (1, 1, 1)],

Callers 1

gdmr_plot.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected