Skip to content

Commit

Permalink
MNT: Fix matplotlib.cm.get_cmap deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed May 4, 2024
1 parent 6d9aceb commit 1c6c41e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions nireports/reportlets/mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import math
import numpy as np
import nibabel as nb
from matplotlib import colormaps
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
from matplotlib.cm import get_cmap
from svgutils.transform import fromstring
from nilearn.plotting import plot_anat
from nilearn import image as nlimage
Expand Down Expand Up @@ -269,7 +269,7 @@ def plot_slice(
annotate=None,
):
if isinstance(cmap, (str, bytes)):
cmap = get_cmap(cmap)
cmap = colormaps[cmap]

est_vmin, est_vmax = _get_limits(dslice)
if not vmin:
Expand Down Expand Up @@ -359,7 +359,7 @@ def plot_slice_tern(
):

if isinstance(cmap, (str, bytes)):
cmap = get_cmap(cmap)
cmap = colormaps[cmap]

est_vmin, est_vmax = _get_limits(dslice)
if not vmin:
Expand Down
10 changes: 5 additions & 5 deletions nireports/reportlets/nuisance.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import os.path as op

import numpy as np
from matplotlib import colormaps
import matplotlib.pyplot as plt
from matplotlib.cm import get_cmap
import seaborn as sns
from matplotlib.backends.backend_pdf import FigureCanvasPdf as FigureCanvas
from matplotlib.gridspec import GridSpec, GridSpecFromSubplotSpec
Expand Down Expand Up @@ -274,9 +274,9 @@ def plot_carpet(
legend = False

if cmap is None:
colors = get_cmap("tab10").colors
colors = colormaps["tab10"].colors
elif cmap == "paired":
colors = list(get_cmap("Paired").colors)
colors = list(colormaps["Paired"].colors)
colors[0], colors[1] = colors[1], colors[0]
colors[2], colors[7] = colors[7], colors[2]

Expand Down Expand Up @@ -469,7 +469,7 @@ def spikesplot(
ntsteps = ts_z.shape[1]

# Load a colormap
my_cmap = get_cmap(cmap)
my_cmap = colormaps[cmap]
norm = Normalize(vmin=0, vmax=float(nslices - 1))
colors = [my_cmap(norm(sl)) for sl in range(nslices)]

Expand Down Expand Up @@ -597,7 +597,7 @@ def spikesplot_cb(position, cmap="viridis", fig=None):
cax = fig.add_axes(position)
cb = ColorbarBase(
cax,
cmap=get_cmap(cmap),
cmap=colormaps[cmap],
spacing="proportional",
orientation="horizontal",
drawedges=False,
Expand Down

0 comments on commit 1c6c41e

Please sign in to comment.