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

Skip to content

Commit 512aecb

Browse files
authored
Merge pull request #14540 from anntzer/sphinxswitchbackend
Simplify backend switching in plot_directive.
2 parents 1eaf40f + faeebe6 commit 512aecb

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,24 +141,17 @@
141141
import sys
142142
import textwrap
143143
import traceback
144-
import warnings
145144

146145
from docutils.parsers.rst import directives, Directive
147146
from docutils.parsers.rst.directives.images import Image
148147
import jinja2 # Sphinx dependency.
149148

150149
import matplotlib
151150
from matplotlib.backend_bases import FigureManagerBase
152-
try:
153-
with warnings.catch_warnings(record=True):
154-
warnings.simplefilter("error", UserWarning)
155-
matplotlib.use('Agg')
156-
except UserWarning:
157-
import matplotlib.pyplot as plt
158-
plt.switch_backend("Agg")
159-
else:
160-
import matplotlib.pyplot as plt
151+
import matplotlib.pyplot as plt
161152
from matplotlib import _pylab_helpers, cbook
153+
154+
matplotlib.use("agg")
162155
align = Image.align
163156

164157
__version__ = 2

0 commit comments

Comments
 (0)