# Make Energy Diagram in Origin

Energy diagram is widely used in the field of physics and chemistry to depict energy changes. The following graph shows the energy splitting of Hydrogen molecule caused by various physics interactions. We will show in this blog the steps to generate such graph in Origin. Please also download the attached zip file to see the final result.

Note: To make energy diagram you need Origin version 2017 SR1 or later. We presume that the data of energy is initially organized as below. Each column corresponds to the energy levels of Hydrogen under each physics effect. When no effect is considered, energy is a constant of 10 (col(B)). While after all effects are taken into account, the energy is split into 8 levels displayed in col(E). 1. We first need to rearrange the data. Highlight col(B) to col(E) in the above worksheet, right click and select Copy in the context menu. Create a new workbook Book2, select cell A1, right click and select Paste Transpose, which results in the worksheet like below: 2. Next we make a copy of each column and put it aside. The reason of doing so will be explained later. This can be done either manually or using the following Labtalk script:

```newsheet;
range rsrc = 1!;
range rdst = 2!;
rdst.ncols = rsrc.ncols*2;
for (int ii = 0; ii < rsrc.ncols; ii++)
{
range r1 = 1!\$(ii+1);
range r2 = 2!\$(2*ii+1);
range r3 = 2!\$(2*ii+2);
colcopy irng:=r1 orng:=r2;
colcopy irng:=r1 orng:=r3;
}```

The worksheet should look as following. 3.  Further arrange the data by (a) adding a column at the beginning with row indices and (b) setting the column type to XYYY… 4. Highlight Col(B)Col(C), select from menu Plot:Bar:Floating Columns to generate the plot. With the graph page active, select menu Window:Script Window, run Labtalk Script  page.BarShowZero = 1 to show the level lines.  Notice here how we utilize the floating column plot to plot the energy levels.  Since the start and end y value of each floating column is the same, each column appears as a horizontal line.  It is necessary to run the above Labtalk script to show the  horizontal lines. This setting can also be set globally. Select menu Tools:Options… , switch to Graph tab and check the checkbox Bar Graph Show Zero Values (New checkbox in Origin 2017 Sr1). 5. Double click the plot to open up the Plot Details dialog. Select Layer1 in the left panel, select Stack tab in the right panel. Check the checkbox besides Show Connect Line on Stacked/Floating Column/Bar. This setting connects levels with dashed lines. Also customize the energy level display according to the settings below:   6. Now we add other energy levels into the graph. Highlight col(D)col(E), move the cursor to the edge of the selected area, hold down mouse and drag&drop the two columns into the graph to add it. 7. Repeat step 6 for all other column pairs and graph should look like below: 8. Now we want to apply the format of the first plot to all other plots. Select the first plot, right click on it and in the context menu, choose Copy Format. Select menu Edit: Paste Format(Advanced)…. In the dialog, select Active Layer in the dropdown list of Apply Scope. Click Appy. 9. Select each plot. Use Line/Border Color icon from Toolbar to customize each plot color 10.  Finalize the graph by adding text and removing unwanted axes.  