Python Forum
Plotting data over a year
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plotting data over a year
#1
Hi!

I want to plot movements over a year but dont get it to work. Do anyone have any suggestions that could help?

class Corrections:
    def __init__(self, data):
        self.data=data 
    def DataError (self):
        movements=[]
        date=[]
        time=[]
        for n in enumerate(self.data):
            c=n[1].split()
            date.append(c[0])
            time.append(c[1])
            movements.append(int(c[2]))
        LN=[]
        for n in range(len(time)-1):
            LN.append(int(time[n][0:2])*24*60+int(time[n][3:5])*60+int(time[n][6:8]))
        for k in range(len(LN)-1):
            if LN[k+1]-LN[k] > 160:
                LN.insert(k+1,LN[k]+120)
                date.insert(k+1,date[k]) 
                movements.insert(k+1,movements[k])
        for n in range(0, len(movements)-1):
            if movements[n+1]-movements[n]>4:
                movements[n+1]=movements[n]+4
            if movements[n+1]<movements[n]:
                movements[n+1]=movements[n]
        movement=np.diff(movements)
        self.date=date
        self.LN=LN
        self.movement=movement

Corrections(test).DataError()

class Registeredmovements(Corrections:
    def __init__(self,givendate):
        self.givendate=givendate
    def plotting(self):
        Y=[]
        D=[]
        for i in [i for i,x in enumerate(self.date) if x==givendate]:
            return i
        Y.append(self.date=date[i:i+281050])
        D.append(self.LN=LN[i:i+281050])
        M.append(self.movements=movements[i:i+281050])
    plot(Y,M)
    plt.show()
print(Registeredmovements('2015-01-25').plotting())
Reply
#2
Is this school/homework assignment?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Yes it is
Reply
#4
sorry to say that, but to be honest your code is total mess. before you start thinking of plotting your data you need to be able to read your data in suitable format and you can print meaningful data. At the moment your code is full of errors
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
I´ve got my data but don´t know what I should do to make it work. So not evan the correction class is right?
Reply
#6
From a quick look I don't see obvious errors, like there are in the Registeredmovements class (whee you have even obvious Syntax errors). But of course I cannot test. Also, I'm not sure what Corrections class should/is expected to yield. However there are plenty of stuff that can be written better/in more pythonic way
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
okay,thank you anyway
Reply
#8
Hi!

I have a question about how to sum data from a file over a year. The file have about 720 data values in one day and i want to make that into a list over a hole year and then plot it. Can anyone help me?
Reply
#9
Please, don't start new thread. I merged your new thread in the original one
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Applied Data Science with Python - homework 2.2 (Weather plotting) eyavuz21 4 3,326 Jun-03-2020, 07:09 PM
Last Post: eyavuz21

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020