diff --git a/gwinc/__main__.py b/gwinc/__main__.py index 3b87cf880cdf6a883a19f949e4f5594d3a617f48..5650137b8726e1f66be2553fb7e935ebcce382ee 100644 --- a/gwinc/__main__.py +++ b/gwinc/__main__.py @@ -3,7 +3,6 @@ import os import signal import argparse import numpy as np -from matplotlib import pyplot as plt from IPython.terminal.embed import InteractiveShellEmbed import logging @@ -136,6 +135,18 @@ def main(): v = float(v) range_params[p] = v + if args.save: + # FIXME: this silliness seems to be the only way to have + # matplotlib usable on systems without a display. There must + # be a better way. 'AGG' is a backend that works without + # displays. but it has to be set before any other matplotlib + # stuff is imported. and we *don't* want it set if we do want + # to show an interactive plot. there doesn't seem a way to + # set this opportunistically. + import matplotlib + matplotlib.use('AGG') + from matplotlib import pyplot as plt + ########## # main calculations diff --git a/gwinc/plot.py b/gwinc/plot.py index 3194705aebe261ec82c5915d3e45ad3d0e09b151..6381918f89754609bf92af7ec2d84287bbc18c64 100644 --- a/gwinc/plot.py +++ b/gwinc/plot.py @@ -1,7 +1,4 @@ from numpy import sqrt -import matplotlib.pyplot as plt - -import logging PRIORITY_MAP = { 'Quantum Vacuum': 0, @@ -80,6 +77,7 @@ def plot_noise( f = noises['Freq'] if ax is None: + import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(1, 1, 1)