Skip to content

Commit

Permalink
Modify matplotlib backend to PDF inside plot function
Browse files Browse the repository at this point in the history
  • Loading branch information
zonca committed Feb 12, 2020
1 parent 42fe297 commit 37e95a5
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions sotodlib/hardware/vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
"""

import numpy as np

import matplotlib
matplotlib.use("pdf")
import matplotlib.pyplot as plt

import quaternionarray as qa
import warnings


default_band_colors = {
Expand All @@ -24,8 +20,18 @@
}


def plot_detectors(dets, outfile, width=None, height=None, labels=False,
bandcolor=None):
def set_matplotlib_pdf_backend():
import matplotlib

matplotlib.use("pdf")
import matplotlib.pyplot as plt

return plt


def plot_detectors(
dets, outfile, width=None, height=None, labels=False, bandcolor=None
):
"""Visualize a dictionary of detectors.
This makes a simple plot of the detector positions on the projected
Expand All @@ -45,6 +51,16 @@ def plot_detectors(dets, outfile, width=None, height=None, labels=False,
None
"""
try:
plt = set_matplotlib_pdf_backend()
except:
warnings.warn(
"""Couldn't set the PDF matplotlib backend,
focal plane plots will not render properly,
proceeding with the default matplotlib backend"""
)
import matplotlib.pyplot as plt

xaxis = np.array([1.0, 0.0, 0.0], dtype=np.float64)
zaxis = np.array([0.0, 0.0, 1.0], dtype=np.float64)
wmin = 1.0
Expand Down

0 comments on commit 37e95a5

Please sign in to comment.