Skip to content

Commit 6b1b46c

Browse files
committed
Merge branch 'master' of https://github.com/matplotlib/cmocean
2 parents bcd314a + 670276b commit 6b1b46c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

cmocean/cm.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import numpy as np
1414
import os
15+
from matplotlib import colors, cm
1516

1617
from . import tools
1718

@@ -34,5 +35,16 @@
3435
cmap_d[cmapname + '_r'] = tools.cmap(rgb[::-1, :], N=256)
3536
cmap_d[cmapname + '_r'].name = cmapname + '_r'
3637

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+
3749
# make colormaps available to call
3850
locals().update(cmap_d)

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[metadata]
2+
license_file = LICENSE.txt

0 commit comments

Comments
 (0)