Display Date and Time Tick Labels in Multiple Lines

posted in: Graphing | 0

For graph with date and time axis, we can easily customize the display to only show information we are interested in, such as only show year, or month and date, etc. But how to show them into multiple lines for a neater look such as the image below?

dateformat_feagure

 

This blog will summarize various options user may consider to customize the tick labels.

Please keep in mind that Origin’s mathematical system for date and time data is based on the Julian Day so that no matter what is displayed in worksheet or axis tick labels, the julian date is used in calculation and plotting.

Please download the attached opj file with a simpler data so you can follow the steps in blog. Unzip and open the opj file in Origin. There are two folders. results folder has 3 graphs with customized tick labels. Go to data folder to follow the steps.

a. Wrap Text Checkbox to Auto Wrap

  1.  Under data folder, highlight column B and make a Line+symbol plot.
  2. Double click the x axis to go into the axis dialog. Under Scale tab, under Major Ticks branch, set Value to 1.5week. Click Apply. Now 5 major ticks are showing on the x axis.
  3. Go to Tick Labels tab. On Display sub-tab, Type is Date. Display dropdown list lists all built-in displays Origin support. You can also choose Custom Display to define your own display.
    dateformat_axis3
  4.  Let’s set Display to 2016/12/14 HH.mm.ss. Click Apply. We can see in the graph, the x axis tick labels are running into each other.
    dateformat_fig1
  5. Go to Format sub-tab. Check Wrap Text checkbox and click Apply. The tick Labels are now separated into two lines.
    dateformat_axis4dateformat_fig2

b. Turn on Minor Tick label for Two Line Tick Labels

The Wrap Text checkbox automatically decides where to wrap so it may not display as you want. We can turn on Minor Tick Label at major tick position to create a two-line tick label effect and specify exactly what we want to display for each line.

  1. Again highlight column B of Book1 and make a symbol-line plot.
  2. In the x axis dialog. Under Scale tab, under Major Ticks branch, set Value to 1.5week.
  3. Go to Tick Labels tab. On Display sub-tab, set Display to 2016/12/15.
  4. Go to Minor Tick Labels sub-tab. Make the following changes:
    1. Minor Tick Labels: Show at Specified Indices Only;
    2. Tick Indices: 1 — means show minor tick label at major tick position.
    3. Offset Major by (%): 100 — this will move major tick label down to get two line tick label effect
    4. Display Format: D5.  D5 means the 6th item from the Display dropdown list on Display tab, which is the 3 letter abbreviation for days of week e.g. Mon, Tue.
      dateformat_dialog2
  5. Click OK. The tick labels are now showing in two lines.

dateformat_fig3

Note:

  • This method guarantees a two-line tick label regardless of the length of each label.
  • Only D0, D1, … kind of syntax can be used. You can customize it to be something not in the dropdown list.

 

c. Wrap Text with Custom Display for Multi-line Tick Labels

In case you need a more sophisticated display of the tick label, e.g., separate the label text to multiple lines, you may consider this method.

  1. Follow step 1,2 in the above procedure to plot the graph.
  2. Go to Tick Labels tab, on Display sub-tab, Set Display to Custom Display.
  3. A new edit box called Custom Display shows below it. Here you can freely define what to display.
  4. Paste the following text: ”      hhtt             MMMdd            ———       yyyy” and click Apply button. Note: More format specifiers can be referred here.
  5. The tick label is customized to a single-line tick label: time, month in 3 letters, date, dashes and year. 
    dateformat_dialog3
  6. Go to Format sub-tab and check the box Wrap Text. Click OK.
    dateformat_fig4

The tick labels will display in 4 lines. Wrap Text auto decides where to wrap. That’s why we added many blank spaces before and after each part to make label in each line center aligned.

Leave a Reply