Skip to content

Commit 514c089

Browse files
authored
Use colormaps instead of deprecated get_cmap (#6483)
Top-level functions in mpl.cm are deprecated since maptlotlib version 3.6. The replacement .ColormapRegistry class is exposed in matplotlib.colormaps since version 3.5 [1]. [1] https://github.com/matplotlib/matplotlib/blob/main/doc/api/next_api_changes/deprecations/23668-TC.rst
1 parent 7eb4a47 commit 514c089

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

skimage/future/graph/rag.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ def rag_boundary(labels, edge_map, connectivity=2):
446446
return rag
447447

448448

449-
@require("matplotlib", ">=3.3")
449+
@require("matplotlib", ">=3.5")
450450
def show_rag(labels, rag, image, border_color='black', edge_width=1.5,
451451
edge_cmap='magma', img_cmap='bone', in_place=True, ax=None):
452452
"""Show a Region Adjacency Graph on an image.
@@ -498,7 +498,7 @@ def show_rag(labels, rag, image, border_color='black', edge_width=1.5,
498498
>>> lc = graph.show_rag(labels, g, img)
499499
>>> cbar = plt.colorbar(lc)
500500
"""
501-
from matplotlib import colors, cm
501+
from matplotlib import colors, colormaps
502502
from matplotlib import pyplot as plt
503503
from matplotlib.collections import LineCollection
504504

@@ -516,12 +516,12 @@ def show_rag(labels, rag, image, border_color='black', edge_width=1.5,
516516
# Ignore the alpha channel
517517
out = image[:, :, :3]
518518
else:
519-
img_cmap = cm.get_cmap(img_cmap)
519+
img_cmap = colormaps[img_cmap]
520520
out = color.rgb2gray(image)
521521
# Ignore the alpha channel
522522
out = img_cmap(out)[:, :, :3]
523523

524-
edge_cmap = cm.get_cmap(edge_cmap)
524+
edge_cmap = colormaps[edge_cmap]
525525

526526
# Handling the case where one node has multiple labels
527527
# offset is 1 so that regionprops does not ignore 0

0 commit comments

Comments
 (0)