-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_helper.py
More file actions
41 lines (31 loc) · 1.17 KB
/
plot_helper.py
File metadata and controls
41 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import matplotlib.pyplot as plt
class PlotHelp(object):
def __init__(self):
pass
def plot_examples(self, examples, potential_labels=None):
"""
examples : List of Mel Spectrogrames of audio data
potential_labels : If not None, we take the supplied examples as
Positive cases where 'Activate' is Present
"""
if potential_labels:
assert len(examples) == len(potential_labels)
nrows = len(examples)
ncols = 1
fig, ax = plt.subplots(nrows, ncols, figsize=(24 * nrows, 12))
if nrows == 1:
ax.imshow(examples[0] )
if potential_labels:
start, end = potential_labels[0]
ax.axvline(start, color='r')
ax.axvline(end, color='r')
plt.show()
else:
for row in range(nrows):
ax[row].imshow(examples[row])
if potential_labels:
start, end = potential_labels[row]
ax[row].axvline(start, color='r')
ax[row].axvline(end, color='r')
plt.title('Examples')
plt.show()