Last active
January 24, 2020 02:21
-
-
Save agarny/e694b973d70682f40493b4679960e830 to your computer and use it in GitHub Desktop.
Plot data contained in a CSV file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import matplotlib.pyplot as plt | |
import sys | |
t = [] | |
y = [] | |
with open(sys.argv[1], 'r') as csv_file: | |
for row_nb, row in enumerate(csv.reader(csv_file)): | |
if row_nb == 0: | |
y_size = len(row) - 1 | |
for i in range(y_size): | |
y.append([]) | |
else: | |
t.append(row[0]) | |
for i in range(y_size): | |
y[i].append(row[i + 1]) | |
for i in range(y_size): | |
plt.plot(t, y[i], label='y{}'.format(i+1), marker='o') | |
plt.legend() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment