Skip to content

Instantly share code, notes, and snippets.

@agarny
Last active January 24, 2020 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agarny/e694b973d70682f40493b4679960e830 to your computer and use it in GitHub Desktop.
Save agarny/e694b973d70682f40493b4679960e830 to your computer and use it in GitHub Desktop.
Plot data contained in a CSV file
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