Working with date/time data in Grapher

Grapher has the capability to generate a graph using data associated with dates, times, or both. When the data in the worksheet is stored in date/time format, Grapher will typically recognize the format and generate the axis displaying the dates. By default, Grapher adheres to your Windows locale setting, but you can customize the date/time formats. Furthermore, you can customize the date/time formats on your data and graph axis.

 

 

Modify date/time formatting, including non-English labels

Grapher automatically adjusts your plot date/time formats according to your Windows system locale language. Additionally, you can manually set the date/time format to any preferred language. If the custom date/time format used is not recognized by Grapher or if you wish to modify the date/time formatting or interval, follow these steps:

  1. Select the axis.
  2. In the Property Manager window, click on the Labels.
  3. Click the Expand Button.png next to the General section to expand it, if necessary
  4. In the General section, in the Use date/time format field make sure the box is checked.
  5. In the General section, in the Major label date/time format field click the Select button.
  6. The Date/Time Format Builder window will pop up.
    1. Select the appropriate language in the Language (Country) list and click the Insert button. For instance, you might select German (Germany) - [$407].
    2. Select the appropriate Predefined date/time formats option and click Insert. For instance, you might select dd.MMM.yyyy.
    3. If the date format you want is not listed, type the date/time format in the Date/Time format (edit to change) box. You can use the M, d, yy, g, h, m, ss, and tt designators. For example, if you want full month names, type MMMM. Verify the Sample looks as expected:
      date_time_format_builder.png
    4. Click OK and the date/time format is displayed on the axis in the set format.

 

Combining separate date time columns

Many programs format data files with time, date, and plotting value in separate columns. When all times are from the same date, the time column suffices for graphing. However, for multiple days, combining date and time into one column is necessary for accurate graph display. Within Grapher, you have the option to combine the date and time columns and place the outcome in a new column.
  1. Display the data worksheet in a new tab, in the Object Manager window right click on your data layer and select Display Worksheet. 
  2. Make note of a few things about your data.
    1. Date column. [For the example below, A]
    2. Time column. [For the example below B]
    3. First row of date/time data to be combined. [For the example below 1]
    4. Last row of date/time data to be combined. [For the example below 100]
  3. Click Data Tools | Data | Transform
  4. The Transform window will pop up.
    1. In the Transform with: dropdown select Column variables (e.g., C = A + B)
    2. For the Transform equation: use the information from step 2 to build your equation.
      1. [Target Column] = [date column] + [time column]
      2. For this example : D=A+B
    3. Fill in the First row and Last row that you took note of in step 2. For this example they are row 1 and row 100.
    4. Click OK
      Transform Window.png
  5. Now you can format the new date/time column.
    1. Select the column that contains your new date/time data.
    2. Click Data Tools | Format | Format Cells.
    3. The Format Cells window will be displayed.
    4. In the Type section select Date/Time.
    5. In the Date/Time format section click in the box to enter the formatting you desire or click the [...] button to the right to open the Date/Time Format Builder window.
    6. Click OK.
  6. You can now use this new column to create a plot in Grapher.

 

Keep date/time format from reverting to numbers or text 

Grapher can read dates and times in data files, but some formats, like BLN, don't support date/time formatting in worksheets. If your graph is empty or date/time format changes to text upon reopening, your file format may not support it. If your data is saved to a BLN file, follow these steps to save your file and preserve your date/time formatting.

  1. Click the File | Open command in Grapher.
  2. Select the file and click Open.
  3. Highlight the column that should be date/time format.
  4. Click the Data Tools | Data | Text to Number command to convert any text to numbers.
  5. Click the Data Tools | Format | Format Cells command.
  6. In the Format Cells dialog window, in the Type section select Date/Time and set the desired Date/Time format. Click OK.
  7. Click the File | Save As command.
  8. Change the Save as type to DAT Data (*.dat), XLS Excel Spreadsheet (*.xls), or XLSX Excel 2007 Spreadsheet (*.xlsx). Type a new File name and click Save.

The data is now stored in a format that supports date/time formatting within the worksheet. To reference this new file, click on your plot in the Object Manager, then remapping your worksheet in the Plot tab of the Property Manager.

 

 

Displaying Numeric Values as Dates

The number 1 can symbolize any date or time, and the increment is flexible, determined by the time interval of your choice. For example, the value 2 can refer to the next day if you’re using a serial date format, or, the value 2 can represent an entirely different time interval.

 

In the example below, value 1 (not shown) represents January 1, 2012, and the data gets collected every day so the interval is one day. The value 2 then represents January 2, 2012; the value 3 represents January 3, 2012, and so on.

Can Grapher display date_time labels for non-standard date numbers in the worksheet_ (226629447)_non-standard_numeric_dates.png
The dates in the left column are in
custom numeric format. Grapher will
set the axis to numeric when creating the graph.

 

Creating date/time axes

To create a graph from date/time data, click the Graphs | Create | <graph category> | <plot type> command. Select the data file and click Open. The appropriate axis will automatically be in date/time format.

 

Setting the date/time interval on an axis

  1. In the Property Manager window select the date/time axis you want to adjust the interval of. 
  2. Click on the Ticks tab.
  3. In the Major Ticks section, check the box next to the Use date/time spacing option.
  4. Click the Every Year button next to Date/time spacing.
  5. Date/Time Spacing window will pop up.
  6. Set the interval and units for the major tick marks. If you want a quarterly tick mark, you would increase the number in the Every box to 3 and select Month from the dropdown list.
  7. Click OK and the major tick marks are now showing the desired number of labels.

    updated_date_time_axis.png

 

Graphing numeric values as dates

You can create a graph that displays date/time labels on your axis when your data contains numeric values. But Grapher requires additional steps to convert numbers to dates.

To create a graph from this data, select your two worksheet columns and click the Home | New Graph | Line/Scatter | Line Plot command. The X axis will be in numeric format.

Can Grapher display date_time labels for non-standard date numbers in the worksheet_ (226629447)_non-standard_number_axis.png
The X axis is automatically displayed with numbers instead of dates.

 

After the graph is created, the axis can be converted to dates. To convert the numbers to dates:

  1. In the Object Manager, click on the X Axis 1 to select it.
  2. In the Property Manager, click on the Labels tab.
  3. In the General section, verify that Use date/time format is unchecked.
  4. Set the Label source to Numeric date/time.
  5. Click the Set button next to Date/time settings.
  6. In the Date/Time Labels dialog:
    1. Set the Axis value to 1.
    2. Set the Date to 1/1/2012.
    3. Set the Time to 12:00:00 AM.
    4. Set the Axis increment to 1
    5. Set the Corresponding time increment to Day.
    6. Click the Set date/time format button and set the Language (Country) and Predefined date/time formats to the desired format, such as English (United States) - [$409] and MMM-dd. If a predefined format is not listed, you can type the desired format in the Date/Time format (edit to change) box. Click OK.
    7. Click OK.

The axis converts your numeric values to dates using the non-standard number sequence you defined.

Note: Your axis tick label format must be set in the Format option in the Date/Time Labels dialog above.

Formatting your tick labels in the Label Settings section of the Property Manager will not affect the axis. This is because your axis is using a non-standard number sequence instead of traditional date/time formatting.

X_Axis_date_time_values.png
The X axis is changed to display with date/time values.

 

 

 

Updated Jan 2024

Was this article helpful?
5 out of 12 found this helpful

Comments

0 comments

Please sign in to leave a comment.