From d5a60cd4999bdceb61765434021fe8d94f8f815d Mon Sep 17 00:00:00 2001 From: Fisch Date: Sun, 16 May 2021 18:55:43 +0200 Subject: [PATCH] matplotlib scatter plot for cmd vs speed --- logdata_visualization/analyze.py | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 logdata_visualization/analyze.py diff --git a/logdata_visualization/analyze.py b/logdata_visualization/analyze.py new file mode 100644 index 0000000..dfe513c --- /dev/null +++ b/logdata_visualization/analyze.py @@ -0,0 +1,52 @@ +import matplotlib.pyplot as plt +import csv + +x=[] +speed_FrontL=[] +speed_FrontR=[] +speed_RearL=[] +speed_RearR=[] + +fp = open('LOG00193_20210516_fixedSpeedLR_freewheelingTest.TXT') + +rdr = csv.DictReader(filter(lambda row: row[0]!='#', fp)) +for row in rdr: + #print(row) + x.append(float(row['cmd_FrontL'])) + + speed_FrontL.append(float(row['speed_FrontL'])) + speed_FrontR.append(float(row['speed_FrontR'])) + speed_RearL.append(float(row['speed_RearL'])) + speed_RearR.append(float(row['speed_RearR'])) +fp.close() + + +#plt.plot(x,y, label='Loaded from file!') +scattersize=5 +scatteralpha=0.1 +plt.scatter(x,speed_FrontL, s=scattersize, alpha=scatteralpha, label="speed_FrontL") +plt.scatter(x,speed_FrontR, s=scattersize, alpha=scatteralpha, label="speed_FrontR") +plt.scatter(x,speed_RearL, s=scattersize, alpha=scatteralpha, label="speed_RearL") +plt.scatter(x,speed_RearR, s=scattersize, alpha=scatteralpha, label="speed_RearR") +plt.xlabel('cmd') +plt.ylabel('speed') +plt.title('Interesting Graph\nCheck it out') +plt.legend() +plt.show() + + +''' +with open(,'r') as csvfile: + plots = csv.reader(filter(lambda row: row[0]!='#', csvfile), delimiter=',') + for row in plots: + x.append(float(row[0])) + y.append(float(row[1])) + +plt.plot(x,y, label='Loaded from file!') +plt.xlabel('x') +plt.ylabel('y') +plt.title('Interesting Graph\nCheck it out') +plt.legend() +plt.show() +''' +