Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d0fb05

Browse files
authored
Merge pull request #14284 from meeseeksmachine/auto-backport-of-pr-14279-on-v3.1.x
Backport PR #14279 on branch v3.1.x (In case fallback to Agg fails, let the exception propagate out.)
2 parents 035e19b + 0215237 commit 1d0fb05

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/pyplot.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,21 @@ def switch_backend(newbackend):
198198
# Don't try to fallback on the cairo-based backends as they each have
199199
# an additional dependency (pycairo) over the agg-based backend, and
200200
# are of worse quality.
201-
for candidate in ["macosx", "qt5agg", "qt4agg", "gtk3agg", "tkagg",
202-
"wxagg", "agg"]:
201+
for candidate in [
202+
"macosx", "qt5agg", "qt4agg", "gtk3agg", "tkagg", "wxagg"]:
203203
try:
204204
switch_backend(candidate)
205205
except ImportError:
206206
continue
207207
else:
208208
rcParamsOrig['backend'] = candidate
209209
return
210+
else:
211+
# Switching to Agg should always succeed; if it doesn't, let the
212+
# exception propagate out.
213+
switch_backend("agg")
214+
rcParamsOrig["backend"] = "agg"
215+
return
210216

211217
backend_name = (
212218
newbackend[9:] if newbackend.startswith("module://")

0 commit comments

Comments
 (0)