TTT4260/D3/grafer/graphs.py

40 lines
777 B
Python
Raw Normal View History

2020-10-04 23:39:15 +02:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 13 16:30:58 2019
@author: oyvind
"""
import csv
import matplotlib.pyplot as plt
header = []
data = []
filename = "Trekantpuls3k"
with open(filename + ".csv") as csvfile:
csvreader = csv.reader(csvfile)
header = next(csvreader)
for dataplot in csvreader:
print(dataplot)
values = [float(value) for value in dataplot]
data.append(values)
time = [p[0] * 1000 for p in data]
ch1 = [p[1] for p in data]
ch2 = [p[2] for p in data]
plt.figure(figsize=(12,5))
plt.plot(time,ch1, time,ch2)
plt.xlabel("Tid (ms)")
plt.ylabel("Spenning (V)")
plt.legend(["Trekantpuls","Firkantpuls"], loc="upper right")
plt.savefig(filename + ".png", dpi=300)
plt.show()