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
- Combining separate date time columns
- Keep date/time format from reverting to numbers or text
- Creating date/time axes
- Setting the date/time interval on an 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:
- Select the axis.
- In the Property Manager window, click on the Labels.
- Click the next to the General section to expand it, if necessary
- In the General section, in the Use date/time format field make sure the box is checked.
- In the General section, in the Major label date/time format field click the Select button.
- The Date/Time Format Builder window will pop up.
- Select the appropriate language in the Language (Country) list and click the Insert button. For instance, you might select German (Germany) - [$407].
- Select the appropriate Predefined date/time formats option and click Insert. For instance, you might select dd.MMM.yyyy.
- 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:
- Click OK and the date/time format is displayed on the axis in the set format.
Combining separate date time columns
- Display the data worksheet in a new tab, in the Object Manager window right click on your data layer and select Display Worksheet.
- Make note of a few things about your data.
- Date column. [For the example below, A]
- Time column. [For the example below B]
- First row of date/time data to be combined. [For the example below 1]
- Last row of date/time data to be combined. [For the example below 100]
- Click Data Tools | Data | Transform.
- The Transform window will pop up.
- In the Transform with: dropdown select Column variables (e.g., C = A + B)
- For the Transform equation: use the information from step 2 to build your equation.
- [Target Column] = [date column] + [time column]
- For this example : D=A+B
- 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.
- Click OK
- Now you can format the new date/time column.
- Select the column that contains your new date/time data.
- Click Data Tools | Format | Format Cells.
- The Format Cells window will be displayed.
- In the Type section select Date/Time.
- 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.
- Click OK.
- 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.
- Click the File | Open command in Grapher.
- Select the file and click Open.
- Highlight the column that should be date/time format.
- Click the Data Tools | Data | Text to Number command to convert any text to numbers.
- Click the Data Tools | Format | Format Cells command.
- In the Format Cells dialog window, in the Type section select Date/Time and set the desired Date/Time format. Click OK.
- Click the File | Save As command.
- 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.
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
- In the Property Manager window select the date/time axis you want to adjust the interval of.
- Click on the Ticks tab.
- In the Major Ticks section, check the box next to the Use date/time spacing option.
- Click the Every Year button next to Date/time spacing.
- A Date/Time Spacing window will pop up.
- 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.
- Click OK and the major tick marks are now showing the desired number of labels.
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.
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:
- In the Object Manager, click on the X Axis 1 to select it.
- In the Property Manager, click on the Labels tab.
- In the General section, verify that Use date/time format is unchecked.
- Set the Label source to Numeric date/time.
- Click the Set button next to Date/time settings.
- In the Date/Time Labels dialog:
- Set the Axis value to 1.
- Set the Date to 1/1/2012.
- Set the Time to 12:00:00 AM.
- Set the Axis increment to 1.
- Set the Corresponding time increment to Day.
- 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.
- 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.
The X axis is changed to display with date/time values.
Updated Jan 2024
Comments
Please sign in to leave a comment.