From 5fed10646d3afeb27bc08d5122785d96cd14e4b1 Mon Sep 17 00:00:00 2001 From: Bernard Knueven Date: Tue, 22 Feb 2022 11:27:35 -0700 Subject: [PATCH] enabling interactive graphics --- egret/viz/generate_graphs.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/egret/viz/generate_graphs.py b/egret/viz/generate_graphs.py index ad5fc416..4a0c9587 100644 --- a/egret/viz/generate_graphs.py +++ b/egret/viz/generate_graphs.py @@ -1,12 +1,17 @@ import os +import sys from collections import namedtuple, defaultdict import datetime import textwrap import matplotlib as mpl -## catch when we're running linux without X -if os.name == 'posix' and 'DISPLAY' not in os.environ: - mpl.use('Agg') +if not hasattr(sys, 'ps1'): + # Not in interactive mode, so use the AGG backend for + # systems without GUIs (which probably will not be run + # in interactive mode). See the discussion on + # https://stackoverflow.com/questions/2356399/tell-if-python-is-in-interactive-mode + # and the definition https://docs.python.org/3/library/sys.html#sys.ps1 + mpl.use('AGG') import matplotlib.pyplot as plt import matplotlib.ticker as ticker