Set Date and Time as the x axis in Numbers

Hello everyone,


I have a csv with data from my glucose monitor with a date column, a time column and a glucose level column. When I make a chart it shows the glucose vs Date but not the time.

The monitor also records (manually input) insulin doses that I've administered in the same format but in a separate table. With out explaining diabetes in too much detail, its important for me to see the effect of the insulin on glucose over a period of time. I take a multitude of glucose reading during the day and only take insulin when needed. When I add this data to the above chart, logically with out the times as a reference, it matches the insulin reading next to the glucose but simply in order which aligns glucose and insulin when they may have been at different times of day and thus I cannot interpret the effect of the insulin.


Can any one suggest a simple way to resolve this? I'm afraid I'm not an in depth numbers user.


TIA,

Mike


User uploaded file


User uploaded file

Posted on Dec 12, 2016 9:35 AM

Reply
5 replies

Dec 16, 2016 1:28 AM in response to themikeyd1

Hi Mikey,


Two points here:


  • For an x-y scatter chart, both parts of the data pair (time, including date; glucose reading) must be in non-header cells.
  • When you enter a time, the date on which it is entered is automatically included.


With these points in mind, try formatting the cells in column B (time) as Date and Time, with both parts showing. Here's an illustration with two shots of the same table. In the first, all columns have been left at 'Automatic'. In the second, columns A and C have been set to Date & Time, with the date set to display as shown, and the time set to use a 24 hour time format. Note that the dates in columns A and C are a day later than the same entries in your table. This is because I entered only the time part and did that today (Dec 12).


Automatic:

User uploaded file

A & C formatted as described:

User uploaded file

Before producing the chart(s), I changed the formatting in column A to match the 'all-numeral' version in column D.

Here's the resulting table, and the chart(s) produced. Details below.

User uploaded file

The chart is actually two charts, one superimposed on the other.

The first chart was made by selecting Cells A2—B9, then choosing x-y scatter from the charts button menu. The only edits to the default chart were to change "no connections" to "curve" and to change the value label orientation on the x axis to "vertical left".

For the second chart, I selected C2—D5 and again chose x-y scatter from the charts button menu.

For this chart, I left the connections pop-up menu at No connections, selected one of the data points and changed the shape and colour of the data points to green diamonds, set the maximum Y axis value to 20 (to match the first chart), hid the x and y axis labels by setting them to white and 0% opacity, set the y value grid lines to none, and hid the legend (as it would be in the same location as the 'glucose' legend when the charts were superimposed).


Then I used the mouse and the alignment guides to drag the second chart and align the two charts' x axes. With the second chart selected, I went to the Arrange menu and moved it one step toward the back, then used the left arrow (and the shift key) to move it leftward and behind the first.


Note that the first insulin dose is shown much earlier on the chart than in the data, as I neglected to account for the difference in start times of the two sets of data.


The result is as shown above.


It is also possible (and a lot less trouble) to put both series of data onto the same chart, but there is one difficulty: If lines or curves are used to connect the data points, a gap in the data with result in a gap in the line or the curve.

In this case, that won't be much of a problem if the insulin doses are taken (or recorded as being taken) at the same time as one of the glucoses measurements. In the first day's data, this is true for one of the three doses, but not true for the other two. I've treated the first and last dose records differently to demonstrate the effect of each treatment on the chart. The first has been recorded as taking place at the same time as the closest glucose level check; the last gets a separate entry, which causes a gap in the data list for glucose, and a corresponding gap in the curve between the last two data points for glucose.

User uploaded file


Finally, here's an image of the first chart(s) with an adjustment to the width of the insulin chart to correct the time placement error mentioned above.

User uploaded file

Regards,

Barry

Dec 13, 2016 2:39 AM in response to themikeyd1

Hi Mickey,

If the date and the time columns are text when you open the CSV in Numbers, there is a way to reconstruct a Date & Time format that Numbers will recognise and use in a Scatter Plot.

When entering (or importing) a date in Numbers, the missing time portion defaults to midnight (0:00) at the start of that day.

When entering (or importing) a time in Numbers, the missing date portion defaults to the day on which it was entered (or imported).

User uploaded file

The table on the left "CSV" is the table that appears on opening a CSV in Numbers. I am assuming that Date and Time are text.

The table on the right is where you can massage the data ready for a Scatter Plot. One Header Row.

I am using Day Month Year to make this more "international".

Formula in A2 (and Fill Down)

=DATEVALUE(CSV::A2)

That converts the Text date to a Date & Time Value and inserts the missing time as 0:00 (midnight)


User uploaded file

Formula in B2 (and Fill Down

=LEFT(CSV::B2,2)&"h"&RIGHT(CSV::B2,2)&"m"

That constructs a text string to show the Duration (hours and minutes) since midnight.


Formula in C2 (and Fill Down)

=A2+B2


You may want to double check the Cell Data Formats.

Select Columns C and D. Insert 2D Scatter.

User uploaded file

With a Scatter Plot, the actual X-axis data are not used. Instead, Numbers calculates even steps. If you want the actual X data, use a Category Chart such as 2D Line.

Numbers has many ways where you can graph both glucose and insulin against time. Please call back with questions

Regards,

Ian.

Dec 16, 2016 1:31 AM in response to themikeyd1

Hi Ian and Barry,


Firstly, I never expected such detailed answers so thank you very much for taking the time to help me with so much information. I had spoken to Apple who couldn't (didn't want to) help.

Secondly, I apologies that after all of your work, I took so long to reply!


I have used the information to create what I needed and in the process, following both of your guidance, I have learnt a huge amount about Numbers in general.


Thank you again and have a Merry Christmas and a Happy New Year.


Mike

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.

Set Date and Time as the x axis in Numbers

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