Skip to content

Commit

Permalink
Avoid a deprecation warning from matplotlib 3.11 (dev)
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Nov 26, 2024
1 parent 59c3500 commit eeac3df
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmocean/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ def _register_cmap(cmap, *, name):
rgb_with_alpha = np.zeros((rgb.shape[0],4))
rgb_with_alpha[:,:3] = rgb
rgb_with_alpha[:,3] = 1. #set alpha channel to 1
reg_map = colors.ListedColormap(rgb_with_alpha, N=rgb.shape[0])
assert len(rgb_with_alpha) == rgb.shape[0]
reg_map = colors.ListedColormap(rgb_with_alpha)
_register_cmap(reg_map, name=f'cmo.{cmapname}')

# Register the reversed map
reg_map_r = colors.ListedColormap(rgb_with_alpha[::-1,:], N=rgb.shape[0])
reg_map_r = colors.ListedColormap(rgb_with_alpha[::-1,:])
_register_cmap(reg_map_r, name=f'cmo.{cmapname}_r')

# Load inverted cmaps
Expand All @@ -71,9 +72,10 @@ def _register_cmap(cmap, *, name):
rgb_with_alpha[:,3] = 1. #set alpha channel to 1

# Register inverted cmaps
reg_map_i = colors.ListedColormap(rgb_with_alpha, N=rgb_i.shape[0])
assert len(rgb_with_alpha) == rgb_i.shape[0]
reg_map_i = colors.ListedColormap(rgb_with_alpha)
_register_cmap(reg_map_i, name=f'cmo.{cmapname}_i')
reg_map_r_i = colors.ListedColormap(rgb_with_alpha[::-1,:], N=rgb_i.shape[0])
reg_map_r_i = colors.ListedColormap(rgb_with_alpha[::-1,:])
_register_cmap(reg_map_r_i, name=f'cmo.{cmapname}_r_i')

# order shouldn't matter
Expand Down

0 comments on commit eeac3df

Please sign in to comment.