diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index 59f10f6b13f..adcccff059b 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -36,6 +36,7 @@ # **************************************************************************** import os +from numbers import Integral from collections.abc import Iterable from math import isnan import sage.misc.verbose @@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None, weight=lopts.pop('font_weight', 'medium'), variant=lopts.pop('font_variant', 'normal')) color = lopts.pop('back_color', 'white') + if 'loc' in lopts: + loc = lopts['loc'] + if isinstance(loc, Integral): + # matplotlib 3.8 doesn't support sage integers + lopts['loc'] = int(loc) leg = subplot.legend(prop=prop, **lopts) if leg is None: from warnings import warn