Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dafc5e0

Browse filesBrowse files
committed
Don't warn in show() when running a non-interactive backened headless.
On Linux, $DISPLAY is unset, then we can't run a GUI toolkit anyways, so don't warn about that in `show()`. Delete the Note in the docstring which was redundant with the Parameters entry.
1 parent 495e0bd commit dafc5e0
Copy full SHA for dafc5e0

File tree

Expand file treeCollapse file tree

1 file changed

+5
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-8
lines changed

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import numpy as np
1919

2020
from matplotlib import rcParams
21-
from matplotlib import docstring
21+
from matplotlib import backends, docstring
2222
from matplotlib import __version__ as _mpl_version
2323
from matplotlib import get_backend
2424

@@ -415,12 +415,8 @@ def show(self, warn=True):
415415
Parameters
416416
----------
417417
warn : bool
418-
If ``True``, issue warning when called on a non-GUI backend
419-
420-
Notes
421-
-----
422-
For non-GUI backends, this does nothing, in which case a warning will
423-
be issued if *warn* is ``True`` (default).
418+
If ``True`` and we are not running headless (i.e. on Linux with an
419+
unset DISPLAY), issue warning when called on a non-GUI backend.
424420
"""
425421
try:
426422
manager = getattr(self.canvas, 'manager')
@@ -436,7 +432,8 @@ def show(self, warn=True):
436432
return
437433
except NonGuiException:
438434
pass
439-
if warn:
435+
if (backends._get_running_interactive_framework() != "headless"
436+
and warn):
440437
warnings.warn('Matplotlib is currently using %s, which is a '
441438
'non-GUI backend, so cannot show the figure.'
442439
% get_backend())

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.