Skip to content

Commit 889252b

Browse files
authored
Matplotlib 3.9 changed their API (#3572)
1 parent f58f5ba commit 889252b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

firedrake/pyplot/mpl.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ def facet_data(typ):
162162
color_key = "colors" if tdim <= 2 else "facecolors"
163163
boundary_colors = boundary_kw.pop(color_key, None)
164164
if boundary_colors is None:
165-
cmap = matplotlib.cm.get_cmap("Dark2")
165+
# matplotlib.cm.get_cmap was deprecated in Matplotlib 3.9, see:
166+
# 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
167+
try:
168+
cmap = matplotlib.cm.get_cmap("Dark2")
169+
except AttributeError:
170+
cmap = matplotlib.colormaps["Dark2"]
166171
num_markers = len(markers)
167172
colors = cmap([k / num_markers for k in range(num_markers)])
168173
else:

0 commit comments

Comments
 (0)