Skip to content

Commit

Permalink
Plot doa: allow to pass ax
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-hld committed Feb 27, 2024
1 parent bd5546c commit 4f3d6ef
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions spaudiopy/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ def decoder_performance(hull, renderer_type, azi_steps=5, ele_steps=3,


def doa(azi, zen, p=None, size=250, c=None, alpha=None, fs=None, title=None,
ltitle=None):
ltitle=None, ax=None):
"""Direction of Arrival, with optional p(t) scaling the size.
Examples
Expand All @@ -1011,6 +1011,10 @@ def doa(azi, zen, p=None, size=250, c=None, alpha=None, fs=None, title=None,
spa.plot.doa(azi, zen, ps, fs=fs, ltitle="p(t)")
"""
if ax is None:
fig, ax = plt.subplots(constrained_layout=True)
ax.set_aspect('equal')

# shift azi to [np.pi, np.pi]
azi[azi > np.pi] = azi[azi > np.pi] % -np.pi
# zen to elevation
Expand All @@ -1026,9 +1030,6 @@ def doa(azi, zen, p=None, size=250, c=None, alpha=None, fs=None, title=None,
if alpha is None:
alpha = 0.35 * np.ones_like(azi)

fig, ax = plt.subplots(constrained_layout=True)
ax.set_aspect('equal')

# plot in reverse order so that first reflections are on top
if c is None and fs is not None: # t in ms
t_ms = np.linspace(0, len(azi) / fs, len(azi), endpoint=False) * 1000
Expand Down

0 comments on commit 4f3d6ef

Please sign in to comment.