Skip to content

Commit

Permalink
Fix colormaps registration due to matplotlib > 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdoc committed May 20, 2024
1 parent d8d73c0 commit b8675a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions cortex/dataset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

default_cmap = options.config.get("basic", "default_cmap")

# register_cmap is deprecated in matplotlib > 3.7.0 and replaced by colormaps.register
try:
from matplotlib.cm import register_cmap
except ImportError:
from matplotlib import colormaps
from matplotlib import colormaps as cm
def register_cmap(cmap):
return colormaps.register(cmap)
return cm.register(cmap)
except ImportError:
from matplotlib.cm import register_cmap


def normalize(data):
Expand Down
9 changes: 5 additions & 4 deletions cortex/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
from .testing_utils import INKSCAPE_VERSION
from .volume import anat2epispace

# register_cmap is deprecated in matplotlib > 3.7.0 and replaced by colormaps.register
try:
from matplotlib.cm import register_cmap
except ImportError:
from matplotlib import colormaps
from matplotlib import colormaps as cm
def register_cmap(cmap):
return colormaps.register(cmap)
return cm.register(cmap)
except ImportError:
from matplotlib.cm import register_cmap


class DocLoader(object):
Expand Down

0 comments on commit b8675a7

Please sign in to comment.