Skip to content

Commit

Permalink
use newer mpl.colormaps object
Browse files Browse the repository at this point in the history
  • Loading branch information
dionhaefner committed Jun 4, 2024
1 parent 4290edf commit b8a1b53
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions terracotta/cmaps/generate_cmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"""

import numpy as np
import matplotlib.cm as cm
import matploblib as mpl

from terracotta.cmaps.get_cmaps import SUFFIX

ALL_CMAPS = list(cm.cmaps_listed) + list(cm.datad)
ALL_CMAPS = list(mpl.colormaps)
ALL_CMAPS.extend([f"{cmap}_r" for cmap in ALL_CMAPS])
NUM_VALS = 255

Expand All @@ -17,7 +17,7 @@ def generate_maps(out_folder: str) -> None:
x = np.linspace(0, 1, NUM_VALS)
for cmap in ALL_CMAPS:
print(cmap)
cmap_fun = cm.get_cmap(cmap)
cmap_fun = mpl.colormaps[cmap]
cmap_vals = cmap_fun(x)
cmap_uint8 = (cmap_vals * 255).astype("uint8")
np.save(f"{out_folder}/{cmap.lower()}{SUFFIX}", cmap_uint8)
Expand Down

0 comments on commit b8a1b53

Please sign in to comment.