In this blog, we will show how to make a timeline, or chronological chart in Origin. We will use the events of the recent financial crisis as the example, with the final graph shown below.

To make this graph, the following Origin features were used:
- String manipulation using Set Values dialog. Notice the timeline labels were shown using two different colors, with the date part highlighted. Here we took the dates and events and combine them together, utilizing custom LabTalk functions defined in the Before Formula Scripts.
- Linked X Axes to have the same time range showing different increment. As you can see, the middle X axis shows the start of each year with a one year increment, while the bottom X axis showing two quarters increment.
- Connect Data Labels to Leader Line with Step-Vert Control and manually adjusting the position of the bent. This is a new feature that requires Origin 2015 SR1.
We have put together an Origin Project (OPJ) that includes two folders: the Start Graph folder and Final Graph folder.You can download this OPJ file (TimeLine-for-Financial-Crisis.zip) so as to follow the steps in this blog. To begin with, please turn to the Start Graph folder: there is a workbook with first sheet Events to list the date and major events from 2006 to 2014, the second sheet SP500 and another sheet with the Fed Funds Rate. Start Graph folder also includes a simple double-Y graph to plot the Fed Funds Rate on the left Y axis and SP500 on the right. This graph can be used as the starting point so that we can focus on the key points.
Preparing the Data Worksheet
After you enter the Start Graph folder in OPJ file, the first thing you need to do is add two extra columns – Col (C) and Col (D) to the Events sheet. Lets also name Marks for Col (C), Labels for Col (D). The Labels column is to store the text labels that will be shown on the timeline. The Marks column we are going to just fill it with zeros (put 0 into the F(x)= row will do), and we will use it as the data plot for the base of our text labels. Here is what the Events sheet looks like, with Date, Events, Marks, and Labels:
In the next section, you will learn how to produce the labels from Date and Events.
Constructing the Graph Labels from Raw Data
As you can see in Fig.1, the timeline labels are the combination of the Date and Events, with the Date part formatted with a different color and are in bold. To do so, we need to write a little bit of code to construct the labels. Origin’s Set Values dialog allows a LabTalk function to be defined in Before Formula Scripts, and then use that function as the formula. Here is what we need to do:
- Open the Set Values dialog for Labels column (select column and right-click to choose Set Column Values).
- Paste
combine(col(a),col(b))$
into formula box. - Paste the following into Before Formula Scripts:
function string combine(double dd, string event$) { string str1$; string strDate$ = Date2str(dd,"MMM','dd','yyyy")$; str1$ = "\c11(\b(" + strDate$ + "))%(CRLF)" + event$; return str1$; }
As you can see, the combine
function defined in the Before Formula Scripts takes a numeric input (double type) dd
as a Julian-day value of the date and a string type event$
as another input, and return a string as its result. Labtalk functionDate2str
is used to convert the date (Julian-day value ) into MMM,dd,yyyy format. In addition, Escape Sequences \c11
and \b
was used to make the Date into maroon bold shown in graph like this:
Apr,02,2007
and%(CRLF)
is a Labtalk Reserved Keyword to insert a new line, and the result is the text you see on Fig. 1.
Creating Linked Time Axis with Different Ticks Label
With the data ready, we can now work on making the graph. As you can see we have included a starter graph called Graph1-Timeline which has two layers to plot the Sp500 and Fed Fund Rate on each. We could simply add the timeline labels into either the 1st or the 2nd layer, but as you can see Fig 1., there is also a middle X axis that showed different increment, and the simplest way to do that is to add a 3rd layer. Since there will be a 3rd layer, it makes sense to just have one plot in each, so that timeline labels will best to be added into this 3rd layer. Having the timeline labels in its own layer will make it simpler in situation where a Re-scale is used.
Lets now add this 3rd layer and link it to the first layer (SP500), and to share the same size and position on the graph page. We should link this new layer’s X axis (middle) to the 1st layer (bottom X axis) by Custom linking, not a Straight link, thus allowing the 3rd layer is to have different X axis increment while sharing the From and To in X:
- Select Graph: New Layer(Axes) Top-X (Linked Y Scale and Dimension) to add a new layer in the graph.
- Select Format: Layer Properties and go to Link Axes Scales tab, link the layer to SP500, and set Custom (X1=x1; X2=x2) as X axis link, while set None as Y Axis link, click OK to apply, as shown below:
- Now we will hide the top X axis and move the bottom X axis to the middle. Double-click to open the X Axis dialog, or select Format: Axes: X Axis to open it, go to Line and Ticks tab. Use Show Line and Ticks box to hide Top axis and show bottom axis, then set the x axis at position y=0, click Apply to apply the settings.
- Next we will customize the tick labels to show yyyy. Go to Ticks Label tab, to show Bottom and hide Top as well, and set the Type and Display to Date and 2015, respectively.
- Next we will set the increment to one year. Go to the Scale tab, set the horizontal scale as shown in figure below, notice that the Increment value is 12 month, which is different from the 6month of bottom axis, and we set the First Ticks with 1/1/2007, which means that the first year shown will be 2007 on timeline. As for Y axis, we set the Vertical scale from -1 to 1,to make sure X axis locate at the middle of the graph, click OK to close the dialog. You can notice in Fig. 1. that bottom axis show increment of 6 month and middle axis just display the year as ticks.
After finished the axis settings, you can further specify the axis color and line width.
Adding the Timeline Labels as a Scatter Plot
After the layer and axes are setup, we can add the label, and basically it is a scatter plot of the Marks column to postion each label in X and Y=0, and the data labels from the Labels column:
- Select Graph: Layer Contents in Origin menu, send Marks Column in worksheet to right panel, and set as Scatter plot type, click OK close the dialog.
- You see some symbols are added on time Axis now. Next we will change the symbol to be short vertical lines which can indicate the exact time positions better.
- Double-click to open the Plot Properties dialog, and set the symbol shape and color as shown below:
Then you can turn to Label tab to set the leader line which is introduced in next section.
Customizing Position and Leader Line for Labels
As you can see in Fig.1, the event labels are connected to their respective date by leader lines, and we will show you how to do that. First, we need to set up the leader line in Label tab of Plot Properties dialog, as shown below:You can see that the Enable box is checked to turn on the data labels, and the Col (D): Labels is designated as Label From. Also, note that the Center is defined as label position, and the Vertical is selected as the connection type for Leader Line.
Origin 2015 supports 7 kinds of leader lines, but for a horizontal timeline, Vertical and Step-Vert leader lines will work best. A new parameter to control Step-Vert bent position was introduced in Origin 2015 SR1, which allows users to specifies the percent position before the bent, as shown below:
The Label for timeline events added on the graph may not locate in a proper position, you need to adjust the position of each Data label manually to avoid overlap, namely:
- Clicking each data label twice to make it a special point and drag it to a proper position (see video below).
- If two events are too close to avoid overlap, please use the Step-Vert as connect methods to re-adjust one of them. For example, the events at Sep.07 and Sep.13 are very close. Thus, you need to slow click twice the event at Sep, 13 or to control double-click it to open the Plot Properties dialog and change the connection type into Step-Vert, then, set a proper value for the position of bent. In this case, value 100 is used, then, you can drag the data label to right to avoid overlapping.
Let’s go back and take a look at the finished timeline graph Fig. 1. Lets review the tips covered in this blog:
- To enter multi-line text into a worksheet cell, Use Ctrl+Enter to start the next line.
- Set Column Values can handle text manipulations.
- Custom axis linking allows the From and To values to be linked but axis increment to be different.
- Data Labels can be individually dragged by slow clicking twice, or by control -clicking to make the selected label a special point.
- Step-Vert connection is best suited for event labeling when multiple events are concentrated in a short time frame. You can drag the labels to space them out, and to manually control the bent position to avoid any overlapping.
The OPJ you downloaded at the beginning actually contained a subfolder named Final Graph. You can check the finished workbook and timeline graph (Fig. 1.) for details.
“Start Graph folder also includes a simple double-Y graph to plot the Fed Funds Rate on the left Y axis and SP500 on the right. This graph can be used as the starting point so that we can focus on the key points.”
Please how do you create this original graph with the double-Y and same -X. Please help!!
Origin has a built-in plot type called Double-Y.
If you have XYY data in same worksheet or XYXY data in same worksheet, you can highlight the Y data and choose Plot: Multi-Y: Double-Y menu to directly plot it. 1st data will be plotted with left Y. second data will be plotted with right Y. They have shared x range.
While in this example, data are in different worksheet. So what you can do it first choose XY data in Fed Funds Rate sheet. Choose Plot: Multi-Y: Double-Y menu to plot Fed Funds Rate data. It is plotted with left Y axis.
Click 2 layer icon on upper left corner of the graph window to make layer2 active. Then with SP500 sheet active, highlight Y data, move mouse over right edge of the Y column till the cursor changes into a graph icon. Press left mouse to drag and drop the Y data into layer2 of the graph. SP500 data will be plotted against right Y axis.
You can double click plot to customize each plot further.
Thanks, Snow