Skip to content

Commit

Permalink
Fix name of cmap
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdoc committed May 16, 2024
1 parent 2d1ea76 commit d8d73c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cortex/dataset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ def get_cmapdict(self):
if self.cmap not in colormaps:
raise ValueError('Unkown color map %s' % self.cmap)
I = plt.imread(colormaps[self.cmap])
cmap = colors.ListedColormap(np.squeeze(I))
cmap.name = self.cmap
name = self.cmap if isinstance(self.cmap, str) else self.cmap.name
cmap = colors.ListedColormap(np.squeeze(I), name=name)
# Register colormap to matplotlib to avoid loading it again
register_cmap(cmap)

Expand Down
3 changes: 1 addition & 2 deletions cortex/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,8 +1007,7 @@ def get_cmap(name):
colormaps = dict((c[:-4], os.path.join(cmapdir, c)) for c in colormaps)
if name in colormaps:
I = plt.imread(colormaps[name])
cmap = colors.ListedColormap(np.squeeze(I))
cmap.name = name
cmap = colors.ListedColormap(np.squeeze(I), name=name)
try:
register_cmap(cmap)
except:
Expand Down

0 comments on commit d8d73c0

Please sign in to comment.