Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: Fix matplotlib.cm.get_cmap deprecation #98

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading