Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- LINES_PER_TABLE = 5
- TITLE_LINE=0
- LINE_FOR_X_1 = 1
- LINE_FOR_X_2 = 2
- LINE_FOR_Y = 3
- data=[]
- title=[]
- x=[]
- x1=[]
- x2=[]
- y=[]
- f = open("data.csv", "r")
- # turn file lines into list so you can use .index
- for line in f:
- data.append(line)
- with open("data.csv", "r") as f:
- date = list(f)
- for line in data:
- # get line titles
- if data.index(line) % LINES_PER_TABLE == TITLE_LINE:
- title.append(line)
- #get x1
- if data.index(line) % LINES_PER_TABLE == LINE_FOR_X_1:
- temp = []
- for value in line.strip('\n').split(","):
- temp.append(float(value))
- x1.append(temp)
- #get x2
- if data.index(line) % LINES_PER_TABLE == LINE_FOR_X_2:
- temp = []
- for value in line.strip('\n').split(","):
- temp.append(float(value))
- x2.append(temp)
- #get y
- if data.index(line) % LINES_PER_TABLE == LINE_FOR_Y:
- temp = []
- for value in line.strip('\n').split(","):
- temp.append(float(value))
- y.append(temp)
- #calculate x
- for i in range(len(title)):
- x.append([])
- for j in range(len(x1[i])):
- ##equation here##
- x[i].append(x1[i][j]/x2[i][j])
- #plot x vs y
- for i in range(len(y)):
- plt.plot(x[i], y[i], label=title[i])
- ax = plt.gca()
- ax.set_aspect(1)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement