From c7f314b8e668dd8b3f4d81a2ab19a34a3e8450c5 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 23 Jan 2022 22:09:52 +0100 Subject: [PATCH] Display bad format string in error message. I had something like `for i in range(n): plot(..., f"oC{i}")` which works for n up to 10, but for greater values one gets "oC10" which is not supported (which is reasonable, as some single-digit strings are actually *marker* abbreviations); mentioning the full format string in the error message ("Unrecognized character 0 in format string 'oC10'") makes it clearer. --- lib/matplotlib/axes/_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 194f2f63cbaa..85c5ada67dfe 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -197,7 +197,7 @@ def _process_plot_format(fmt): i += 2 else: raise ValueError( - 'Unrecognized character %c in format string' % c) + f'Unrecognized character {c} in format string {fmt!r}') if linestyle is None and marker is None: linestyle = mpl.rcParams['lines.linestyle']