summaryrefslogtreecommitdiff
path: root/plot.py
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-08-26 21:06:41 +0200
committerAki <please@ignore.pl>2022-08-26 21:06:41 +0200
commita35565eb2ee1cccce726e912cd8a66c8126c0d8a (patch)
tree61bfd91f3a3f4377872f7e2e378951575e9382b2 /plot.py
downloadszilagyi-a35565eb2ee1cccce726e912cd8a66c8126c0d8a.zip
szilagyi-a35565eb2ee1cccce726e912cd8a66c8126c0d8a.tar.gz
szilagyi-a35565eb2ee1cccce726e912cd8a66c8126c0d8a.tar.bz2
Implemented stub that plots the dataset
Diffstat (limited to 'plot.py')
-rw-r--r--plot.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/plot.py b/plot.py
new file mode 100644
index 0000000..1669c5a
--- /dev/null
+++ b/plot.py
@@ -0,0 +1,31 @@
+import csv
+import os
+import re
+
+import matplotlib.pyplot as plot
+
+
+def load(directory):
+ def _read(iterable):
+ for x, y in iterable:
+ yield float(x), float(y)
+
+ def _load(filename):
+ with open(filename) as fd:
+ reader = csv.reader(fd)
+ return list(_read(reader))
+
+ def _files(directory):
+ for file in os.listdir(directory):
+ match = re.match(r"SWI_(-?\d+)\.csv", file)
+ if match:
+ yield int(match.group(1)), os.path.join(directory, file)
+
+ return [(x, _load(y)) for x, y in _files(directory)]
+
+
+swis = load("dataset")
+
+for index, data in swis:
+ plot.plot([x[0] for x in data], [x[1] for x in data], label=index)
+plot.show()