How can i plot these data in a multiline graph?
I have tried using these code but only the first value of each line is being added to the list
For my y axis I want to get the values of the appliance multiplying the values of 0.5,0,1,0(For example for line 1,(tv value = 120) I should get 24 plots which are at
y axis :60 and x axis 0
y axis 0 and x axis 1
y axis 120 and x axis 2
and so on... having a total of 24 plots(My y labels will consist of values from 0 to 2200)
For my x axis I will be ploting the values of x_labels
file format
Residents: 4
TV1:120:0.5,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0.5,0,0,0.5,1,1,1,0.5
Computer:320:1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Fridge1:250:1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Dishwasher:500:0.5,1,1,0.5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
Blender:700:0,0,0,0,0,0,0,0,0,0,0,0,0,0.05,0,0,0,0,0,0,0,0,0,0
Fridge2:50:1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Coffee machine:2400:0,0,0,0,0,0,0,0,0,0.05,0.05,0,0,0,0,0,0,0,0,0,0,0,0,0
Kettle:2200:0.05,0,0,0,0,1,0,0,0.05,0,0.05,0.05,0,0,0,0,0.05,0,0,0,0,0.05,0.05,0
Freezer:140:1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Slow cooker:300:0,0,0,0,0,0,0,0,0,0,0,0,0.5,1,1,1,1,1,0.5,0,0,0,0,0
My code
import matplotlib.pyplot as plt
import numpy as np
x = []
y = []
x_labels = ['0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23']
fileobj = open('file.csv','r')
for line in fileobj:
line_s = line.strip()
Usage = [(x) for x in line_s.split(',')]
y.append(Usage[2])
fileobj.close()
plt.plot(y ,"o--")
plt.ylabel("usage")
plt.xlabel("time")
plt.show()
