Commit 062a4e7f authored by Leo Pound Singer's avatar Leo Pound Singer
Browse files

Fix backend dependence of plt.tight_layout

Fixes #352.
parent 758d9ac4
......@@ -23,6 +23,10 @@ Changelog
- Adapt to a change in the GraceDB server's API response for a request to
create a label that already exists.
- Set the matplotlib backend to ``agg`` in order to fix plot layout glitches
that started with matplotlib 3.3.0 when ``plt.tight_layout`` became backend
dependent (see https://github.com/matplotlib/matplotlib/pull/15221).
0.13.0 (2020-06-03)
-------------------
......
......@@ -120,6 +120,9 @@ def make_omegascan(ifo, t0, durs):
bytes of png of the omegascan, or None if no omegascan created.
"""
# Explicitly use a non-interactive Matplotlib backend.
plt.switch_backend('agg')
# Collect data
longest = max(durs)
long_start, long_end = t0 - longest, t0 + longest
......
......@@ -63,6 +63,9 @@ def plot(contents):
>>> contents = '{"HasNS": 0.9137, "HasRemnant": 0.0}'
>>> em_bright.plot(contents)
"""
# Explicitly use a non-interactive Matplotlib backend.
plt.switch_backend('agg')
properties = json.loads(contents)
outfile = io.BytesIO()
......
......@@ -136,6 +136,9 @@ def plot(contents):
>>> p_astro.plot(contents)
"""
# Explicitly use a non-interactive Matplotlib backend.
plt.switch_backend('agg')
classification = json.loads(contents)
outfile = io.BytesIO()
......
......@@ -90,6 +90,9 @@ def plot_allsky(filecontents, ra=None, dec=None):
"""Plot a Mollweide projection of a sky map using the command-line tool
:doc:`ligo-skymap-plot <ligo/skymap/tool/ligo_skymap_plot>`.
"""
# Explicitly use a non-interactive Matplotlib backend.
plt.switch_backend('agg')
# Note: plt.style.context added as workaround for
# https://github.com/astropy/astropy/issues/8004.
with NamedTemporaryFile(mode='rb', suffix='.png') as pngfile, \
......@@ -111,6 +114,9 @@ def plot_volume(filecontents):
"""Plot a 3D volume rendering of a sky map using the command-line tool
:doc:`ligo-skymap-plot-volume <ligo/skymap/tool/ligo_skymap_plot_volume>`.
"""
# Explicitly use a non-interactive Matplotlib backend.
plt.switch_backend('agg')
# Note: plt.style.context added as workaround for
# https://github.com/astropy/astropy/issues/8004.
with NamedTemporaryFile(mode='rb', suffix='.png') as pngfile, \
......@@ -255,6 +261,9 @@ def plot_coherence(filecontents):
Under the hood, this just calls :meth:`plot_bayes_factor`.
"""
# Explicitly use a non-interactive Matplotlib backend.
plt.switch_backend('agg')
with NamedTemporaryFile(content=filecontents) as fitsfile:
header = fits.getheader(fitsfile, 1)
try:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment