From 889252bd34b021d1a0f29a62dc0d0286077a1256 Mon Sep 17 00:00:00 2001 From: Jack Betteridge <43041811+JDBetteridge@users.noreply.github.com> Date: Thu, 16 May 2024 16:24:07 +0100 Subject: [PATCH] Matplotlib 3.9 changed their API (#3572) --- firedrake/pyplot/mpl.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/firedrake/pyplot/mpl.py b/firedrake/pyplot/mpl.py index bd789d5592..984c08f977 100644 --- a/firedrake/pyplot/mpl.py +++ b/firedrake/pyplot/mpl.py @@ -162,7 +162,12 @@ def facet_data(typ): color_key = "colors" if tdim <= 2 else "facecolors" boundary_colors = boundary_kw.pop(color_key, None) if boundary_colors is None: - cmap = matplotlib.cm.get_cmap("Dark2") + # matplotlib.cm.get_cmap was deprecated in Matplotlib 3.9, see: + # https://matplotlib.org/3.9.0/api/prev_api_changes/api_changes_3.9.0.html#top-level-cmap-registration-and-access-functions-in-mpl-cm + try: + cmap = matplotlib.cm.get_cmap("Dark2") + except AttributeError: + cmap = matplotlib.colormaps["Dark2"] num_markers = len(markers) colors = cmap([k / num_markers for k in range(num_markers)]) else: