-
Notifications
You must be signed in to change notification settings - Fork 0
/
freq_est_plot.py
executable file
·54 lines (39 loc) · 1.36 KB
/
freq_est_plot.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
# This program generates scatter plots from .csv files data.
# Run this from within the folder containing the .csv files to
# convert them all into .pdf plots.
#
# Make sure to change the title to reflect your data.
#
# Copyright (c) Dario Sanfilippo 2021
import sys
import glob
import numpy as np
import scipy as sp
import pandas as pd
import matplotlib.pyplot as plt
for filename in glob.glob('*.csv'):
freq = []
error = []
tmp = []
name = []
name = filename
name = name + ".pdf"
data = pd.read_csv(filename)
tmp = data.to_numpy()
l = len(data)
for i in range(l):
freq = np.append(freq, tmp[i][0])
error = np.append(error, tmp[i][1])
print(freq)
plt.xlabel('Frequency (Hz) target')
plt.ylabel('Prediction error (target-ANN ratio complement)')
plt.axhline(y = 0, linewidth = .25, color = 'r', label = "Best fit")
plt.scatter(freq, error, marker = "o", s = .1, linewidth = 1, color = 'black', label = "Prediction error")
#plt.plot(freq, error, marker = ".", linewidth = 0, color = 'black', label = "ANN output")
plt.title("Frequency estimation")
handles, labels = plt.gca().get_legend_handles_labels()
by_label = dict(zip(labels, handles))
plt.legend(by_label.values(), by_label.keys())
plt.grid(True)
plt.savefig(name)
plt.clf()