File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -89,3 +89,21 @@ def cmap(rgbin, N=256):
89
89
cmap = mpl .colors .LinearSegmentedColormap .from_list ('mycmap' , rgbin , N = N )
90
90
91
91
return cmap
92
+
93
+
94
+ def lighten (cmapin , alpha ):
95
+ '''Lighten a colormap by adding alpha < 1.
96
+
97
+ :param cmap: A colormap object, like cmocean.cm.matter.
98
+ :param alpha: An alpha or transparency value to assign the colormap. Alpha
99
+ of 1 is opaque and of 1 is fully transparent.
100
+
101
+ Outputs resultant colormap object.
102
+
103
+ This will lighten the appearance of a plot you make using the output
104
+ colormap object. It is also possible to lighten many plots in the
105
+ plotting function itself (e.g. pcolormesh or contourf).
106
+ '''
107
+
108
+ # set the alpha value while retaining the number of rows in original cmap
109
+ return cmap (cmapin (np .linspace (0 ,1 ,cmapin .N ), alpha ))
You can’t perform that action at this time.
0 commit comments