diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 9afca6ff81eb..819525482cb7 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -18,7 +18,7 @@ import numpy as np from matplotlib import rcParams -from matplotlib import docstring +from matplotlib import backends, docstring from matplotlib import __version__ as _mpl_version from matplotlib import get_backend @@ -415,12 +415,8 @@ def show(self, warn=True): Parameters ---------- warn : bool - If ``True``, issue warning when called on a non-GUI backend - - Notes - ----- - For non-GUI backends, this does nothing, in which case a warning will - be issued if *warn* is ``True`` (default). + If ``True`` and we are not running headless (i.e. on Linux with an + unset DISPLAY), issue warning when called on a non-GUI backend. """ try: manager = getattr(self.canvas, 'manager') @@ -436,7 +432,8 @@ def show(self, warn=True): return except NonGuiException: pass - if warn: + if (backends._get_running_interactive_framework() != "headless" + and warn): warnings.warn('Matplotlib is currently using %s, which is a ' 'non-GUI backend, so cannot show the figure.' % get_backend()) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy