6.4.1 Merging and Arranging Graphs
The Merge Graph Windows dialog allows you to select which graphs you wish to combine, choosing from any graph in the project. It also has controls to specify how you want the individual graphs arranged on the new page.
The Object Edit toolbar allows you to quickly align and size multiple layers.
The Layer Management dialog lets you add, arrange and link layers on a single graph page.
What you will learn
This tutorial will show you how to:
- Resize and align layers quickly
- Add a second axis using a nonlinear relationship with the primary axis
- Use Layer Management for more complex layer positioning and linking
- Merge multiple graphs into one graph
Aligning Layers using the Object Edit Toolbar
- Select File:Open and open the OPJ \Samples\Graphing\Layer Management.opj and go to the subfolder Arranging Layers. (If you don't see the subfolders, click View: Project Explorer to open the Origin Project Explorer window.)
- We want to use the Object Edit tools to rearrange the graph so make sure that this toolbar is visible. If it is not, you can open it from the View: Toolbars dialog box.
- On the graph, hold the Shift key down and click on all four layers to select them as a group. Press the Uniform Width and Uniform Height buttons on the Object Edit toolbar to apply a uniform height and width. Then click on the white space in the layer to deselect all graph layers.
- Hold Shift key to click and select the bottom two layers and then click the Bottom button on the Object Edit toolbar to align them. Click on the white space in the layer to deselect all graph layers.
- Hold Shift key to click and select the top two layers, then click the Top button to align them. Click on the white space in the layer to deselect all graph layers.
- Click and select the top and bottom in the left column, and click the Left align . Click on the white space in the layer to deselect all graph layers.
- Click and select the two in the right column and click the Right align button.
- Do not save changes to your project, as the same project will be used later to demonstrate the usage of Layer Management.
The Object Edit toolbar provides a quick way to align and resize layers. The first layer you select is the reference layer and all others are adjusted relative to the first-selected layer. The Layer Management tool provides additional options such as layer reordering and linking.
Another way to select layers in a multiple layer graph is to press CTRL or SHIFT while clicking on the graph layer icons.
Displaying Opposite Axes with a Nonlinear Formula
An Origin 2D graph layer is a set of X, Y axes, and opposite axes can be turned on for both X and Y. In addition, the opposite axes can also display labels using any user-specified nonlinear formula with respect to the primary axis.
- Using the Project Explorer window, switch to the subfolder named Nonlinear Axis.
- With the graph active, bring up the Layer Management tool by selecting Graph: Layer Management.
- Switch to the Axes tab and expand the Top branch and check the Axis, Title, and Tick Label check boxes.
- We want to display the labels on the top axis in units of Energy and the relationship between wavelength and energy is:
Energy (eV) = 1240/Wavelength (nm)
So in the Formula box, enter: 1240/x and click Apply, then click OK to close the dialog.
- If you are setting up a nonlinear relationship for the right Y-axis, in the Formula you still need to use x instead of y.
- You can also do similar settings in the Axis dialog to add such opposite axis:
- Double-click and edit the top X-axis title and change it to: Energy (eV)
- In the above image, the first tick label of the top axis is a missing value for energy that corresponds to zero wavelength. To hide it, double-click the top axis labels or axis, to open the Axis dialog. Go to the Special Ticks tab in Top icon. Then select Hide in the Axis Begin drop-down list. Click OK to apply the settings and close the dialog.
Using Layer Management to Link and Position Layers
The Layer Management tool can be used to position, resize, swap, and link layers:
- Reopen the project \Samples\Graphing\Layer Management.opj and then switch to the subfolder named Arranging Layers. You can reopen the project by selecting File: Recent Projects: Layer Management.opj. Do not save changes to the project.
- Bring up the Layer Management tool from Graph: Layer Management. In the left panel, rename the layers so that they are, top to bottom: Peak 3, Peak 2, Peak 4, Peak 1. The layer names now correspond to the legend for each layer.
Note: To rename a layer, double-click on the name.
- Now drag and arrange the list on the left so that they are ordered Peak 1, Peak 2, Peak 3, Peak 4. The layer number and names now match.
- Now switch to the Arrange tab and do the following:
- Check Show Axes Frame.
- Set Horizontal Gap and Vertical Gap to 0.
- Click Apply.
This resizes and repositions the layers so they are aligned, and hides ticks and labels where layers overlap.
- Go to the Axes tab, hold down the CTRL key and select Peak 1 and 3 on left list, then expand the Left branch and set tick direction to In, and click Apply.
- Now select Peaks 3 and 4, set the Bottom tick direction to In and click Apply. Then select Peaks 1 and 2, set the Top ticks to In and click Apply.
- go to the Link tab and select Peaks 2, 3, and 4 in the left list and link them to layer 1, making sure you have the X-Axes linked Straight(1 to 1), and click Apply.
Click OK to close the dialog box.
- Click and select the top left layer, layer 1, then drag and resize the layer, then move the layer. Note that the child layers resize and move too, since they are dimensionally linked to layer 1.
- Go to the top left layer (layer 1), and double-click the top X-axis. In the X-Axis dialog, change the X-Axis scale From 10 To 35, and click OK. You'll see that all the other layers now display the same X-axis scale range.
If the layers are linked, they are treated as one unit. If you need to rearrange layers, you should first unlink them. You can re-link layers after arranging.
Merge Multiple Graphs
In this section, we merge two graphs from different subfolders of the same project while treating the four layers in one graph as a unit.
- Click on the Rescale button when the Graph 1 in the Arranging Layers subfolder is active.
- Select Graph: Merge Graph Windows in the main menu to open the dialog.
- Do the following:
- Click the triangle button to the right of Graphs and from the flyout menu choose All in Project. Graph1 and Graph2 will show in the Preview panel (not shown).
- Make sure Number of Rows = 2 and Number of Columns = 1.
- Make sure Treat Each Source Graph As a Unit is selected.
- Set the Vertical Gap to 20.
- Click OK to close the dialog box. A new merged graph page is created: