Skip to content

fix(plot): use matplotlib colormaps registry instead of removed cm.get_cmap - #623

Open
catplotlib wants to merge 1 commit into
petercorke:mainfrom
catplotlib:matplotlib-get-cmap-removal
Open

fix(plot): use matplotlib colormaps registry instead of removed cm.get_cmap#623
catplotlib wants to merge 1 commit into
petercorke:mainfrom
catplotlib:matplotlib-get-cmap-removal

Conversation

@catplotlib

@catplotlib catplotlib commented Aug 22, 2026

Copy link
Copy Markdown

Summary

matplotlib.cm.get_cmap was deprecated in matplotlib 3.7 and removed in 3.9. Two call sites still used it, so both raised AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap' on any current matplotlib (matplotlib is unpinned in pyproject.toml):

  • RobotPlottingMPL.linkcolormap(name) for any named colormap - a public API whose own docstring runblock calls robot.linkcolormap("inferno")
  • DistanceTransformPlanner.plan(animate=True), which failed before computing the distance map

Both are switched to the colormaps registry, with resampled(6) replacing the old lut argument. set_bad/set_over in the revived animate path are folded into with_extremes so executing it does not introduce new PendingDeprecationWarnings.

Neither path was reachable from the test suite - one sat behind # pragma: nocover, the other only runs under animate=True - which is why the earlier migration of PlannerBase.py to mpl.colormaps missed them. Those two now-covered pragmas are dropped.

Related issue

None - found while checking an unrelated colorbar report, not tied to an existing issue.

Checklist

  • PR title follows Conventional Commits (type: description) — checked automatically, see the "Check PR title" status
  • Tests pass locally (pytest) — 632 passed, 72 skipped. The 4 test_bin.py failures also occur on pristine main here (missing ipython extra) and are unrelated.
  • Added/updated tests for this change, if applicable — regression tests for both paths; with the source change reverted they fail with the AttributeError above.
  • New/changed code is type-hinted with modern syntax (X | Y, list[X], not Union/Optional/List) — no signatures added or changed.
  • Docstrings updated (reST style: :param:, :returns:; type hints in the signature cover types now, :type:/:rtype: are rarely needed) — no public API change.
  • PR is as small/focused as practical — one defect, two call sites of the same removed API.
  • No test files, data files, or notebooks specific to your own project

…t_cmap

matplotlib.cm.get_cmap was deprecated in matplotlib 3.7 and removed in
3.9, so both call sites raised AttributeError on any current matplotlib:

- Robot.linkcolormap(name) for any named colormap
- DistanceTransformPlanner.plan(animate=True), which failed before
  computing the distance map

Both paths were unreachable from the test suite (one behind pragma
nocover, one animate-only), so the earlier migration of PlannerBase.py
to mpl.colormaps missed them.

Use the colormaps registry, with resampled(6) replacing the old lut
argument, and fold set_bad/set_over into with_extremes to avoid their
PendingDeprecationWarning. Add regression tests covering both paths.
@catplotlib
catplotlib force-pushed the matplotlib-get-cmap-removal branch from c63677c to 8335441 Compare August 22, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant