diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 8530ecc0c94c..3f9e8bbcb297 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1191,7 +1191,11 @@ def interactive(b): def is_interactive(): 'Return true if plot mode is interactive' - b = rcParams['interactive'] and hasattr(sys, 'ps1') + # ps1 exists if the python interpreter is running in an + # interactive console; sys.flags.interactive is true if a script + # is being run via "python -i". + b = rcParams['interactive'] and ( + hasattr(sys, 'ps1') or sys.flags.interactive) return b def tk_window_focus():