0

I have a dataframe with hours of the day and a column with body activity. I want to plot the activity 'SVM' with hour in x from 12 midday to 12 midday the day after. However the plot automatically plot from 00 to 23. This is part of the code after loading the file:

enter code here

In [16] x = act1[['Time1']].values

In [17] y= act1[['SVM']].values

In [18] y
Out[18]: 
array([[  11.63],
       [  12.13],
       [  12.14],
       ..., 
       [  86.37],
       [ 154.61],
       [ 127.49]])

In [19]  plt.plot(x,y)
Out[19]: [<matplotlib.lines.Line2D at 0x9e7f5c0>]

  • 1
    I assume `x` is between 0 and 24. If so, you need to shift the first half of the values (between 0 and 12), so that they come after the second half (between 12 and 24). – Julien Spronck Jun 12 '15 at 12:26
  • You could also convert the hour data to timestamps, with the 0-11 hours the day after the 12-23. Look up `import datetime`, etc. – cphlewis Jun 13 '15 at 07:30
  • You can make a new dataframe column or a list where you have mapped a given time (your 'Time1') to number of minutes since midday. So midday would map to 0 and 11:59 (the next day) would map to 1439. Now you can plot SVM on these new times. Also, you could create the time labels as a list of strings. If this is a terrible explanation see http://stackoverflow.com/a/30245793/4663466 – Scott Jun 14 '15 at 06:03
  • Thank you for your advises. I will follow your lead. and post the results – Antonio Jun 16 '15 at 12:56

0 Answers0