6.3 Compare Graphs Dynamically by Changing Data Filters


The Copy Columns To.. feature allows you to copy columns from a worksheet to a new worksheet while keeping the two sheets linked. Using this feature you can set multiple Filter conditions on one columns by creating a corresponding number of worksheets. For example to set two Filter conditions on the Column Gas Type we created two sheets Type1 and Type2 that were linked to worksheet Raw.
We also used various features to create a dynamic Graph that would update to reflect the changes in Filter conditions in real time. You can watch the video tutorial explaining these concepts here: https://www.youtube.com/watch?v=N0Pud-91qCM

Minimum Origin Version Required: Origin 2015 SR0

What you will learn

This tutorial will show you how to:

  • Dynamically compare data with different filter conditions
  • Add multiple filter conditions on the same columns using different worksheets
  • Add a dynamic filter label in a graph that updates with changes in the filter condition


This tutorial is associated with the Tutorial Data.opj file under <Origin EXE Folder>\Samples path.

Set Up the Worksheets

Open the Tutorial Data.opj file and browse to the folder Compare Graphs with Filters Data and active workbook Book1. The workskeet Raw contains data for the emission of different green house gases in different countries over a period of years.

  1. Highlight the last three columns : Year, Gas Type, Value
  2. Right click on one of the columns and in the context menu that opens select Copy Columns To...

    Data Filter1 ii.png

  3. In the Copy Columns to: colcopy dialog that opens, change the Recalculate to Auto so later when input data is changed the result will be automatically updated. Also make sure the DestinationColumn(s) is set to <new>!<new> meaning a new worksheet is added, and click OK

  4. Data Filter2.png

  5. Name the new worksheet Type1
  6. Repeat the above procedure and name the second worksheet Type2

  7. Data Filter3i.png

Set Filters

  1. On Sheet Raw highlight column Country and select the Filter button.

  2. Data Filter4.png

  3. This will create a funnel icon on the top left of the Country column. Click on this and in the menu that opens deselect the Select All check box and check the France check box. Click OK

  4. Data Filter5.png

  5. The worksheet now only shows information for the country France.
  6. In Sheet Type1 set a Filter on the Gas Type column for the gas HFCs. Since sheet Raw and sheet Type1 are linked, this worksheet will now show only the HFC emission values for the country France.

  7. Data Filter6.png

  8. In Sheet Type2 set a Filter for Gas Type PFCs. This worksheet now only shows PFC emission values for Country France.

Creating the Graph and Adding a Linear Fit

  1. Without anything highlighted in any of the worksheets go to Plot > Multi-Panel/Axis : Stack....
  2. In the dialog that opens, click on the arrow button next to the Input box and select Select Columns...

  3. Data Filter7.png

  4. In the Data Browser dialog, make sure that List Datasets = in Current Book and select both the Value columns in Sheets Type1 and Type2. Click Add and OK out.

  5. Data Filter8.png

  6. In the Stack: plotstack dialog, set Plot Type to Scatter and click OK. This will create the following graph:

  7. Data Filter9.png

  8. In the newly created graph double click on any axes, in the Scale tab set the Rescale as Auto. Do this for every axes on both plots of this graph so when the worksheet filter is changed and the graph data changes, the axes will rescale automatically.

  9. Data Filter10.png
    Note: By holding the Ctrl key and selecting both Horizontal and Vertical icons, you can change Rescale for X and Y axes in the same layer, simultaneously. Use the Layer drop-down at the bottom of the dialog box to apply changes to both graph layers (i.e. Layer 1 and Layer 2).

  10. Set the Layer drop-down to Layer 1, then click the Tick Labels tab. With Bottom icon selected, change the Display to show just the year.
    Data Filter10b.png
  11. Click the Line and Ticks tab. With the Right icon selected, and set Major and Minor Ticks Style to None and Apply.
    Data Filter10c.png
  12. Set the Layer drop-down list to Layer 2 and repeat for the Top X axis and Right Y axis in Layer 2 and click OK.
  13. Delete the two Y axis title objects at the left part of the graph, add a new text label Value and rotate it to 90 degrees (right click and select Properties to change rotation angle) and use it as the new Y axis title.
  14. Next we're going to do a Linear Fit so the emission trends are more apparent.
  15. Activate the graph and go to Analysis:Fitting: Linear Fit....
  16. Set Recalculate to Auto.
  17. Use the arrow button next to the Input box to select Add all plots in active page. Click OK to close the dialog and perform a linear fit on the two plots.

  18. Data Filter11.png

  19. Double-click on the linear fit curves and go to the Plot Details dialog, in the Line tab, set the color as Red for each curve. Delete the two legend objects and move away the report table. The resulting graph will look like this:

  20. Data Filter12.png

Add Dynamically Changing Labels

  1. Click on the Sheet Type1 and select the Filter label row cell in column B.
  2. Click Edit: Copy: Copy
    Data Filter13.png
  3. Select the Text Tool Data Filter14.png, and click on the graph upper panel. When the blue text box appears hold down Ctrl + Alt + V. This will paste the Data Filter Label as a link into the text box.
  4. Click off of the new text label, then right-click and select Properties.

  5. Data Filter15.png

  6. In the dialog that opens, click on the Programming tab, then check the Real Time check box so the label changes every time the data filter is changed.
  7. Do this with the Filter Labels in Sheet Type2 and Sheet Raw. Add the words "Gas Type" before the "PFC" and "HFC" labels and "Country" before the Country Data Filter Label. Also Add a Layer Title:

  8. Data Filter17.png

Add Floating Graph to the Worksheet

  1. To add the graph to the worksheet, activate the worksheet Raw
  2. Right click on the grey section of the worksheet and in the context menu that opens select Add Graph..

  3. Data Filter18.png

  4. In the Graph Browser dialog that opens, select the graph we just created, and then click OK
  5. Enlarge the graph by selecting it and dragging the edges. If you change the Filter Types in the worksheet now, the graph will update accordingly.