Making Dynamic Inset Graphs

posted in: Graphing | 0

006_2

Oftentimes when plotting data you may find you want to display a zoomed-in section of a graph to make otherwise cluttered graphs more clear to the viewer. Fortunately Origin provides its users with a number of ways to display different portions of their data. To follow this blog, see the linked OPJ file.

Zoom Graph Template

Origin’s zoom graph template makes it easy to plot data with an automatically-generated inset graph. For example– below we see several columns of New York City population data. To plot this data and a zoom-in area, all we need to do is select all of the columns in our worksheet and choose Plot>Specialized>Zoom menu.

001

This generates a graph window with two layers, a top layer which contains the entire range of our data with a cyan rectangle to represent our region of interest, and the bottom which displays the data within this cyan rectangle. By default the template places the first point of data in the center of this rectangle. Whenever we move or resize this region of interest, the bottom layer will be update automatically.

002

We can resize the bottom layer and put it as an inset layer within the top layer. However if we move or resize the top layer, the bottom layer will move with it as it’s linked to this layer. As you can see in the image below, whenever we edit the width of the main graph, our inset graph will rescale with it.

003

To avoid this problem, we can go into the Plot Details dialog and select Layer2 on left panel, change the units in Size/Speed from “% of Linked Layer” to “% of Page”. Then move or resize top layer will not affect the 2nd layer.

004

To add a legend for the graph, choose Graph>Legend> Reconstruct Legend menu or Ctrl+L.

Note: Changing plot color settings in one layer will not change the plot colors in the other. Make sure to set both manually.

006_2

 

Create a Zoomed-in Graph in an Existing Graph Window

012

Let’s say we have a graph window that’s already customized and we want to create a inset graph from this without altering our formatting. In this case there are a couple alternate ways to go about this.

Embedding Enlarged Graphs Using Paste Link (new in the coming Origin 2016 SR1)

  1. With the graph window active, select the Scale Inscale_in button on the toolbar on left side of Origin workspace.
  2. While holding the CTRL key, click and drag a rectangle across the region of interest in the graph. Upon releasing the mouse, Origin will create a new graph window called Enlarged and display two graph windows alongside one another.
  3. To demonstrate the interactive nature of this graph, move the gray region of interest in original, automatically updating the enlarged graph.
  4. In Origin 2016 SR1, with the Enlarged graph window active, choose Edit>Copy Page to copy the whole page.
  5. Right click in original graph and Paste Link.

016

Note:

  • The pasted-linked graph is an object rather than a layer. For this reason all formatting changes need to be made in the Enlarged graph window.
  • If the Enlarged graph window is deleted from the OPJ, then the inset graph will also be deleted.
  • To make inset graph labels legible, the font size in Enlarged graph will need to be made significantly larger to compensate for the graph’s scaling.
  • By default when resizing the paste linked graph, the aspect ratio is kept constant. To modify the proportions of the inset graph, right-click on it, select Properties… and un-check the Keep aspect ratio tickbox.

019

  • By default when moving/resizing the active layer, the pasted-linked graph will be moved/resized as well. To prevent this, right click the paste linked graph and choose Properties… On the Control tab and in the Attach to section, change the option button from Layer Frame to Page.

017

After reconstructing our legend, adding top and right axes, and making other formatting changes, our graph will appear much as it does below.

01823

 

Copying the Zoom Rectangle with its Script
(Origin 2016 SR0 and earlier)

For versions prior to Origin 2016 SR1, inset graphs can be added to projects using elements from both of the aforementioned procedures.

  1. With our main graph window active, select Graph>New Layer(axes)>Inset (linked dimension) to add a blank inset layer.
    m2-002
  2. Then go to a workbook with any Y column selected, and select Plot>Specialized>Zoom to create a new zoom graph. It can be any Y data as we will be copying the region-of-interest rectangle to our original graph.
  3. Click the small cyan rectangle and choose Ctrl+C to copy it. This will copy the object, as well as any script associated with it.
  4. Now in our original graph, with our 1st layer selected (note the small grey button in the upper-left hand corner of the window), we’ll paste this rectangle on our main graph. Whenever this rectangle is moved, the inset layer will update to show the plots in the region of interest.
  5. Since we were only interested in the region of interest rectangle for our original graph, we can delete the Zoom graph generated in step 2.

Note

  • One drawback of this method is that it does not automatically carry the formatting of the main graph to the inset graph. In some versions of Origin it may be best to adjust inset axes formatting after adjusting the region of interest, as moving this rectangle after the fact may cause them to shift out of place (see below).
    m2-006
  • As with other zoom graphs, the inset layer will move/rescale with the main layer unless the default settings are changed in the Plot Details dialog. With 2nd layer selected on the left panel, change units from % of Linked Layer to % of Page on the Size/Speed tab.
  • The inset layer doesn’t automatically group plots as original graph does. To apply the same color scheme to this inset graph this will need to be done manually by double clicking on the number of the inset layer (the 2 in the upper left corner of the graph).This opens the “Layer Contents” dialog window; from here we can select the lines in our graph and group them. Once this has been done, close out of this dialog and open Plot Details. With our inset graph lines grouped we can now change their color scheme to the same color list as our main graph, rather than having to altering them individually.

m2-004
As you can see, after adjusting the formatting and layout of our graphs our graph will look much as it does using the previous two techniques.

m2-007

Leave a Reply