Repository: scikit-image/scikit-image

Issue:
PendingDeprecationWarning with Matplotlib 3.6rc1
## Description

Matplotlib 3.6rc1 was released recently:
https://pypi.org/project/matplotlib/3.6.0rc1/

It adds a pending deprecation warning for `cm.get_cmap`:
https://matplotlib.org/devdocs/api/cm_api.html?highlight=get_cmap#matplotlib.cm.get_cmap

This causing your CI tests to fail.  For instance, on main you currently have this failure:
https://github.com/scikit-image/scikit-image/runs/7941813111?check_suite_focus=true

Here is the failure:
```
=================================== FAILURES ===================================
_________________ [doctest] skimage.future.graph.rag.show_rag __________________
489     Examples
490     --------
491     >>> from skimage import data, segmentation
492     >>> from skimage.future import graph
493     >>> import matplotlib.pyplot as plt
494     >>>
495     >>> img = data.coffee()
496     >>> labels = segmentation.slic(img)
497     >>> g =  graph.rag_mean_color(img, labels)
498     >>> lc = graph.show_rag(labels, g, img)
UNEXPECTED EXCEPTION: PendingDeprecationWarning('The _get_cmap function will be deprecated in a future version. Use ``matplotlib.colormaps[name]`` instead.')
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/doctest.py", line 1334, in __run
    exec(compile(example.source, filename, "single",
  File "<doctest skimage.future.graph.rag.show_rag[6]>", line 1, in <module>
  File "/home/runner/work/scikit-image/scikit-image/skimage/_shared/version_requirements.py", line 136, in func_wrapped
    return obj(*args, **kwargs)
  File "/home/runner/work/scikit-image/scikit-image/skimage/future/graph/rag.py", line 519, in show_rag
    img_cmap = cm.get_cmap(img_cmap)
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 199, in wrapper
    emit_warning()
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 193, in emit_warning
    warn_deprecated(
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 96, in warn_deprecated
    warn_external(warning, category=MatplotlibDeprecationWarning)
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/matplotlib/_api/__init__.py", line 363, in warn_external
    warnings.warn(message, category, stacklevel)
PendingDeprecationWarning: The _get_cmap function will be deprecated in a future version. Use ``matplotlib.colormaps[name]`` instead.
/home/runner/work/scikit-image/scikit-image/skimage/future/graph/rag.py:498: UnexpectedException
=============================== warnings summary ===============================
```


Discussion:

Resolving patch:
diff --git a/skimage/future/graph/rag.py b/skimage/future/graph/rag.py
--- a/skimage/future/graph/rag.py
+++ b/skimage/future/graph/rag.py
@@ -448,7 +448,7 @@ def rag_boundary(labels, edge_map, connectivity=2):
     return rag
 
 
-@require("matplotlib", ">=3.3")
+@require("matplotlib", ">=3.5")
 def show_rag(labels, rag, image, border_color='black', edge_width=1.5,
              edge_cmap='magma', img_cmap='bone', in_place=True, ax=None):
     """Show a Region Adjacency Graph on an image.
@@ -500,7 +500,7 @@ def show_rag(labels, rag, image, border_color='black', edge_width=1.5,
     >>> lc = graph.show_rag(labels, g, img)
     >>> cbar = plt.colorbar(lc)
     """
-    from matplotlib import colors, cm
+    from matplotlib import colors, colormaps
     from matplotlib import pyplot as plt
     from matplotlib.collections import LineCollection
 
@@ -518,12 +518,12 @@ def show_rag(labels, rag, image, border_color='black', edge_width=1.5,
         # Ignore the alpha channel
         out = image[:, :, :3]
     else:
-        img_cmap = cm.get_cmap(img_cmap)
+        img_cmap = colormaps[img_cmap]
         out = color.rgb2gray(image)
         # Ignore the alpha channel
         out = img_cmap(out)[:, :, :3]
 
-    edge_cmap = cm.get_cmap(edge_cmap)
+    edge_cmap = colormaps[edge_cmap]
 
     # Handling the case where one node has multiple labels
     # offset is 1 so that regionprops does not ignore 0


Test patch: