File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 12
12
13
13
import numpy as np
14
14
import os
15
+ from matplotlib import colors , cm
15
16
16
17
from . import tools
17
18
34
35
cmap_d [cmapname + '_r' ] = tools .cmap (rgb [::- 1 , :], N = 256 )
35
36
cmap_d [cmapname + '_r' ].name = cmapname + '_r'
36
37
38
+ # Register the cmap with matplotlib
39
+ rgb_with_alpha = np .zeros ((rgb .shape [0 ],4 ))
40
+ rgb_with_alpha [:,:3 ] = rgb
41
+ rgb_with_alpha [:,3 ] = 1. #set alpha channel to 1
42
+ reg_map = colors .ListedColormap (rgb_with_alpha , 'cmo.' + cmapname , rgb .shape [0 ])
43
+ cm .register_cmap (cmap = reg_map )
44
+
45
+ # Register the reversed map
46
+ reg_map_r = colors .ListedColormap (rgb_with_alpha [::- 1 ,:], 'cmo.' + cmapname + '_r' , rgb .shape [0 ])
47
+ cm .register_cmap (cmap = reg_map_r )
48
+
37
49
# make colormaps available to call
38
50
locals ().update (cmap_d )
You can’t perform that action at this time.
0 commit comments