Graph showing sleep data

Hi!


I have a task that would be easy to accomplish if I were to use a pen and paper, but still seems hard to accomplish in Numbers. I want to create a graph/diagram showing on the Y-axis: time of the day when (A) I went to bed, and (B) I woke up; and on the X-axis: date of that day. I have created a mockup chart showing how I (roughly) want my data to appear. Number's linear chart doesn't seem to accept "time/date" as a value for the Y-axis, so to plot this I had to use a graph diagram (which isn't really accurate):

User uploaded file


The data I have is arranged in a three column table as following: [Date; Time lights out; Time out of bed (next morning)]

The reason the above chart isn't accurate is because I have entered all data as occuring on the same date (+1 if after midnight). If I hadn't, the Y-axis would just increase and increase for each night. And that's my problem: The time-data I want to enter shouldn't be date-specific on the Y-axis, only on the X-axis. Since this is part of a sleep-journal program, I will be making new entries each day (not all at once).


So, my question is: How do I avoid Numbers enterpreting these as consecutive dates and achive the chart I'm looking for?


Thank you,

Sebastian

iMac7,1 Intel Duo 2,8 GHz, 24", 500 GB HDD, 4 GB RAM, Mac OS X (10.6.6), Aluminium wireless keyboard and Magic Mouse

Posted on Feb 10, 2013 9:55 PM

Reply
10 replies

Feb 11, 2013 9:46 PM in response to enigma

I didn't look closely enough at your chart. Aside from the 24 hr problem, you cannot make a chart where the Y axis has a larger number on the bottom than on the top. You will hve to create your Y axis value labels manually. Also, to get below "0:00", the chart cannot be plotting Date & Time values because there is no such thing as negative time.


I consider "sleep time" to be the ending of the day. From that viewpoint, it appears for each date you are entering the previous day's sleep time and the current day's wake time. The vertical distance between the two on the chart therefore indicates the amount of time you slept. I moved my columns around accordingly.



User uploaded file


As explained above, I had to use durations like Jerry did. Columns B, C, F, and G are formatted as durations.


You don't necessarily have to create three new columns. You really only need the one that adjusts the sleep time. But I find it much easier and less error prone and it often takes fewer steps to create charts when the data is all together. You can do it either way.


column E = A

column F = B- DURATION(,,IF(B>C,24,0))

column G = C


Make the scatter chart then do the following:

  • You need to set the Y-axis min and max, you cannot let them be "auto". For the chart in the sceenshot, the max is 16h and the min is -4h and there are 5 steps.
  • Resize the chart to whatever size you want it to be.
  • The Y axis of the chart is actually a table. A plain table, one column. Type in the same Y axis labels that the chart made except for the lowest one which, in this case was a -4:00 and needed to be 20:00.
  • Turn off the chart's Y axis labels and position and resize the table to be the Y-axis labels.
  • Turn off the table borders and set the fill color to none.

Feb 12, 2013 6:23 AM in response to enigma

Here's my suggestion for you, Sebastian.


The Max for your chart value can be more than a day. I suggest that you designate bed times beyond midnight to be part of the next day, timewise. I'm running this chart from 6am to 6am, across Midnight.


User uploaded file

For bed times past midnight, enter then as 1d and xhours. A bed time of 2 am would become, in Duration, 1d 2h.


Jerry

Feb 11, 2013 6:41 AM in response to enigma

The way Numbers handles Date & Time values can be helpful sometimes and painful other times. The problem is that the wake and bed "times" you are entering get tagged with the current day's date. You need to convert them to all be on the same date. What I would do is this:


  1. Lets say Table 1 is your data with the date in column A, wake time in B and bed time in C
  2. Add three more columns to your table. Lets say they are columns E,F,G
  3. Column E = A
  4. Column F = TODAY() + TIMEVALUE(B)
  5. Column G = TODAY() + TIMEVALUE(C)
  6. Select all three columns and plot as a scatter chart. At first it will only plot the wake times. You will have to click the gear and choose "share X values".
  7. In the chart inspector, choose "show hidden data"
  8. Hide those three columns when you are done

Feb 11, 2013 6:51 AM in response to enigma

Hi enigma,


Dates and times are sometimes tricky things to work with. Follow the advice from Wayne and Badunit.


Just for fun, have a play with the Numbers Template "Employee Schedule" to give you some ideas on how Numbers handles Dates and Times.


In Numbers, go to Menu > File > New from Template > Employee Schedule


Open Inspector > Cells and click here and there in the table to see how the formats change from Pop-up Menu (where you choose a time) to Duration (a time difference).


This is not an answer to your question. Simply for you to have a play.


Regards,


Ian.

Feb 11, 2013 7:13 AM in response to Yellowbox

Unless something has changed in that template, it also had problems regarding date & time values. The issue in that template was that if you tried to modify or add to the date & time popups, the new additions would have the current date while the old entries would keep the old date (ie., the date when the designer entered those dates in the popup) and then the time calculations will be way wrong. So, basically the same problem. There were a number of posts on this a long time ago which involved modifying the formulas to use TIMEVALUE.

Feb 11, 2013 7:44 PM in response to Jerrold Green1

Thanks for all your replies!


Jerry and Badunit, both of your suggestions are great. I tried them out, but both of them hit the same brick wall: Crossing that midnight line. Jerry, your sleeping-time estimates were naive. 😉 The very reason I've been ordered to start keeping this kind of sleeping journal is because of my bad sleep habits, meaning I go to bed way too late in the wee hours of morning. But my goal is to introduce a lights-out around 23:00. So, I anticipate a lot of hopping around the the midnight-line for the diagram.


So any solution to that? One preferrably retaining normal hours (not like "27 hrs").


Also, if possible, I'd want the Y-axis of the chart to range from 18:00 hours to 18:00 the following day. That would be the best range I think, placing 06:00 hrs on the middle line.


Thankfully,

Sebastian


PS: Wouldn't it be possible to use the "IF()"-function to add "1" to any time entry later than midnight? I think I read so somewhere, but I'm not too familiar with that function yet.

Feb 12, 2013 5:45 AM in response to enigma

Hi Sebastian,


Here is a thought that might get around the "midnight starts a new day" problem. Numbers (and every app and every computer clock) begins a new day at 12:00 am. That is nonsense (to humans). That displayed time could also be 0:00 hours or 24:00 hours. If a mechanical clock shows 12, is that one millisecond before midnight or one millisecond after midnight?


Instead of considering that each new "day" begins at midnight, it could be more useful to consider that each "night" begins at some other time (such as sunset).


Choose any time as your starting point for a night. It could be 6 pm.


Suppose that you go to bed when the clock shows 11:00 pm. That is 5 hours after the arbitrary start of "night". If you go to bed when the clock shows 2:30 am, that is 8.5 hours after the arbitrary start of "night". Those values (5 hours and 8.5 hours) are numbers (5 and 8.5) and are not Date-and-Time or Duration format. They are *numbers* and can form one axis in your graph.


Ian.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Graph showing sleep data

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.