3
3
4
4
.. seealso::
5
5
6
- :doc:`/gallery/color/colormap_reference` for a list of builtin
7
- colormaps.
6
+ :doc:`/gallery/color/colormap_reference` for a list of builtin colormaps.
8
7
9
8
:doc:`/tutorials/colors/colormap-manipulation` for examples of how to
10
- make colormaps and
9
+ make colormaps.
11
10
12
11
:doc:`/tutorials/colors/colormaps` an in-depth discussion of
13
12
choosing colormaps.
14
13
15
14
:doc:`/tutorials/colors/colormapnorms` for more details about data
16
- normalization
15
+ normalization.
17
16
18
17
19
18
"""
37
36
# reversed colormaps have '_r' appended to the name.
38
37
39
38
40
- def _reverser (f , x = None ):
41
- """Helper such that ``_reverser(f)(x) == f(1 - x)``."""
42
- if x is None :
43
- # Returning a partial object keeps it picklable.
44
- return functools .partial (_reverser , f )
39
+ def _reverser (f , x ): # Toplevel helper for revcmap ensuring cmap picklability.
45
40
return f (1 - x )
46
41
47
42
@@ -50,11 +45,8 @@ def revcmap(data):
50
45
data_r = {}
51
46
for key , val in data .items ():
52
47
if callable (val ):
53
- valnew = _reverser (val )
54
- # This doesn't work: lambda x: val(1-x)
55
- # The same "val" (the first one) is used
56
- # each time, so the colors are identical
57
- # and the result is shades of gray.
48
+ # Return a partial object so that the result is picklable.
49
+ valnew = functools .partial (_reverser , val )
58
50
else :
59
51
# Flip x and exchange the y values facing x = 0 and x = 1.
60
52
valnew = [(1.0 - x , y1 , y0 ) for x , y0 , y1 in reversed (val )]
0 commit comments