Tutorials

Origin’s publication-quality technical graphics are supported by an equally impressive array of data import and analysis features. We have designed these tutorials to help you get a feel for the breadth of Origin’s capabilities


Origin Tutorials

The Origin Tutorials focus on the functionality of Origin’s user interface. Tutorials cover data import, plotting, use of some of Origin’s data exploration and analysis tools, nonlinear curve fitting and the basics of creating a graphic presentation.

Tutorial 1, The Origin Workspace

Tutorial 2, Worksheets, Data Import, and Plotting

Tutorial 3, The Import Wizard

Tutorial 4, The Plot Setup Dialog Box

Tutorial 5, Working with Excel in Origin

Tutorial 6, Exploring your Data

Tutorial 7, Creating Multiple Layer Graphs

Tutorial 8, Templates

Tutorial 9, Themes

Tutorial 10, 3D Surface and Contour Graphs

Tutorial 11, Nonlinear Curve Fitting

Tutorial 12, Creating Presentations with the Layout Page


Tutorial 1, The Origin Workspace

This tutorial will introduce you to components and use of the Origin workspace. We will discuss Origin’s:

  • windows

  • menus

  • toolbars

  • the Project Explorer workspace.


Origin Windows

Origin has numerous windows and workspaces available for completing various tasks. The worksheet is the primary structure for organizing your data. On the surface, the worksheet looks much like a conventional spreadsheet. However, its behavior and capabilities are unique.

When you start Origin, the default workspace opens to display a single worksheet named Data1.

If you have not done so, start Origin. Note the single blank worksheet window named Data1.

To open a fresh Origin worksheet:

  1. From the menu, choose File:New. The New dialog box opens.

  2. Select Worksheet and click OK. A second worksheet is added to the workspace. Note that Origin has automatically named the worksheet Data2.

Notice also that as you opened the new worksheet, the color of the title bar of the Data1 worksheet turned gray. The new worksheet’s title bar is now highlighted, indicating that it is the active window in the Origin workspace. Any commands that you issue to Origin, either through the user interface (the menus, toolbars, etc.) or programmatically (via LabTalk or Origin C), act upon the active window. It is likely that many windows of many different types will be open in the Origin workspace, and the color of the title bar is your primary indicator as to which is the active window.

  3. Click anywhere on the Data1 worksheet. The title bar is highlighted and Data1 becomes the active window. The title bar of Data2 is now grayed out.

Origin keeps track of the various windows in the workspace by assigning a unique name to them. You can assign your own names to worksheet windows, but Origin will not allow you to assign the same name to two windows. Recall that when you opened a second worksheet, Origin automatically assigned the name of Data2 to the worksheet to distinguish it from Data1. The necessity for this naming system will become more apparent as you work with Origin, but for now, suffice it to say that the window name is a unique identifier that allows for manipulation of the window and its contents.

To rename a window:

  1. Right-click once on the window title bar of the Data1 worksheet and select Rename from the shortcut menu (or select Window:Rename from the menu). The Rename dialog box opens.

  2. Enter MyData1 in the Name field but do not click OK just yet.

  3. In the Label field enter Data from Trial 1, select the Both Name and Label radio button, and click OK. Note that spaces are not allowed in window names but spaces are okay in window labels.

  4. Click the Close button [image] in the upper right corner of the Data2 worksheet. An attention box opens asking you to delete or hide the worksheet. Choose Delete. The worksheet closes.

  5. Click the Close button [image] in the upper right corner of the renamed MyData1 worksheet. An attention box opens asking you to delete or hide the worksheet. Choose Delete. The worksheet closes.

To learn more about Origin worksheets, see Tutorial 2, Worksheets, Data Import and Plotting.

Provided you have Excel 7 or later installed, Origin opens, creates, edits, analyzes, graphs, and saves Excel workbook data without leaving the Origin workspace. We will look further at this in a later tutorial, but, for now, let’s just open a fresh Excel workbook.

To open an Excel workbook window:

  1. From the Origin menu, choose File:New. The New dialog box opens.

  2. Select Excel and click OK. A blank workbook opens. Note that the workbook is named Book1.

Note: It may take a moment to open the Excel workbook. In fact, if you are observant, you’ll notice that the program menu structure changes completely as the workbook opens. This is because you are actually running the Excel program within the Origin workspace. Thus, the menus that you see when the workbook opens are actually Excel’s menus.

The Origin graph window is the primary window for plotting in Origin. Origin’s many built-in 2D and 3D graph types use very different specifications (and graph templates) to create a graph, but all graphs – whether 2D or 3D – use the same Origin graph window.

To open an Origin graph window:

  1. Choose File: New from the program’s main menu. The New dialog box opens.

  2. Select Graph and click OK.

or

  2. Click the New Graph button [image] on the Standard toolbar.

A blank graph window opens. Note that the graph window is named Graph1.

Most often you will use the worksheet for tabulating and manipulating your data, while you will use the graph window for plotting your data. However, if you are making 3D surface or contour plots of XYZ data, you will need to become familiar with another window type – the Origin matrix.

The Origin matrix, like the worksheet, superficially resembles a spreadsheet, though it’s purpose is to store the Z coordinates of an XYZ dataset. We will say much more about Origin matrices in a later tutorial, but, for now, let’s just have a look at one.

To open an Origin matrix window:

  1. From the menu, choose File:New.

  2. Select Matrix and click OK. A data window with a pale yellow background opens. The window is named Matrix1.

Origin has another special type of graphing window called a Function window. This window allows you to plot a function without having to create a dataset. Consult you Origin Help file (Help:Origin) for more information on the Function graph.

To open an Origin Function window:

  1. From the menu, choose File: New.

  2. Select Function and click OK. A blank Function window opens. Simultaneously, the Plot Details dialog box will open to the Function tab. This tab allows you to type a function in the bottom text box and plot it in a graph window. As this is just an introduction to the function window, click Cancel in the Plot Details dialog box.

Note: The Plot Details dialog box is Origin’s all-in-one interface for customizing Origin graphs. You will learn more about the Plot Details dialog in later tutorials.

Of course, much of Origin’s utility derives from its presentation quality graphics capabilities and Origin’s Layout window is specifically designed for assembling graphic presentations. While you can combine several graphs on a single graph page, the Layout window is the only window in which you can combine worksheets and graphs.

To open an Origin Layout window:

  1. From the menu, choose File:New.

  2. Select Layout and click OK. A blank Layout window opens.

  3. Right-click in the gray area to the right side of the Layout page (this is the area outside the page but inside the window).

  4. Choose Rotate Page from the shortcut menu. The page orientation changes from landscape to portrait.

The Notes window is a general purpose text window that is useful for making notes to yourself about procedures, to pass information on to others with whom you share your Origin files, to save equations, scripts, mathematical functions, etc.

To open an Origin Notes window:

  1. From the menu, choose File: New.

  2. Select Notes and click OK. A blank Notes window opens.

Origin has another specialized text window that reports and stores your analytical output (statistical results, curve fitting results, etc.). This is the Results Log.

To display the Results Log:

  1. From the menu, choose View:Results Log.

This menu item toggles the Results Log on and off, so that you can conserve screen space when it is not needed. Hiding the Log does not delete the contents; unless cleared, Results Log contents are saved with the Origin Project file.

Another cornerstone of Origin’s power is its programmability. Origin has two programming languages: LabTalk and Origin C. LabTalk is Origin’s proprietary scripting language. The Script window provides a convenient way to issue LabTalk commands in Origin.

To display the Script window:

  1. From the menu, choose Window:Script Window. A blank Script window opens (Note that you can also open the Script window by choosing View:Script Window or by clicking the Script Window button [image] on the Standard toolbar).

  2. Close the Script window by clicking the Close button [image] in the upper right corner of the window.

Origin C is Origin’s new ANSI C-compliant programming language. Origin provides a special workspace known to programmers as an integrated development environment (IDE). This Origin IDE, called Code Builder, is provided for writing, compiling, running and debugging your Origin C programs.

To display the Code Builder integrated development environment:

  1. Choose View:Code Builder from the menu. The Code Builder IDE opens.

  2. Click the Close button [image] in the upper right-hand corner of Code Builder.

There can only be one instance of Code Builder or one Script window opened per instance of Origin. You can toggle the Script window on and off without losing the window contents. To temporarily hide Code Builder, use the minimize button in the upper right hand corner of Code Builder.

To learn more about programming in Origin, see the Command Line and Programming Tutorials.


Origin Menus

Our quick tour of Origin’s many window types probably gave you a hint as to the wide range of Origin’s capabilities. In order to accommodate Origin’s varied capabilities, Origin’s designers have created a context sensitive menu structure. Context sensitive menus present the user with only the commands that are pertinent to the currently active window type (worksheet, graph, matrix, etc.). This helps to speed your work, because you are not forced to wade through dozens of irrelevant or grayed-out menu items to find the one that you are looking for.

To see how this context sensitive menu structure works, do the following:

  1. If you have not done so, start Origin. If you are continuing from the previous Origin windows tutorial, select File:New Project. When prompted to save the contents of your previous session, say No.

At this point, you should have a clean workspace containing a single Origin worksheet.

Origin’s main menu should look like this:

  2. From the menu, choose File:New. The New dialog box opens. Select Graph and click OK. A blank graph window opens.

Origin’s main menu should now look like this:

Note that the menu options have changed. Opening a new graph window made the graph window the active window, and Origin altered the menu structure to hide worksheet-relevant options and make graph-relevant options available to you.

  3. From the menu, choose File:New. The New dialog box opens. Select Matrix and click OK. A blank matrix window opens.

Origin’s main menu should now look like this:

Again, note that the menu structure has changed. When the new matrix window became the active window, the menu structure changed to make matrix-relevant commands available to you. Let’s perform one more operation just to reinforce the point of this short exercise: that Origin’s menu structure changes according to the active window type. If you find that you are suddenly unable to find the menu command that you are looking for, chances are good that you simply need to activate a window of the appropriate type.

  4. From the menu, choose File:New. The New dialog box opens. Select Excel and click OK. A blank Excel workbook window opens.

Origin’s main menu should now look like this:

Note: It may take a moment to open the Excel workbook. When you choose to open an Excel workbook in Origin, you are actually running the Excel program within the Origin workspace. Thus, there may be a several second delay before the program responds.


Origin Toolbars

Origin’s toolbars give you quick access to many of Origin’s menu commands. This tutorial will give you a few pointers on managing your Origin toolbars.

As you work with Origin, you may find that there are some toolbars that you use extensively and others that you use rarely, if at all. You can choose to display or hide any built-in or user-defined toolbar.

To hide or display an Origin toolbar:

  1. Select View:Toolbars from the menu. The Customize Toolbar dialog opens.

The Toolbars tab displays a list of standard Origin toolbars. Those that are active (visible in the workspace) will have a check mark next to them.

  2. Position your cursor over the check box next to the Standard toolbar and click once to clear the box. Notice that the Standard toolbar disappears from the toolbar spacer.

  3. Position your cursor over the check box next to the Standard toolbar and click once to select (restore) the Standard toolbar.

In addition to hiding or displaying toolbars, you can use the Customize Toolbar dialog to add or remove buttons from your toolbars or create new toolbars using a single button or a combination of buttons.

When you choose View:Toolbars from the menu, you enable toolbar edit mode. To see how this works, let’s run through a short exercise.

To customize a toolbar:

  1. Place your cursor over the New Project button [image] on the Standard toolbar (if you closed the Customize Toolbar dialog, reopen it.).

  2. Hold down the left mouse button, drag the New Project button into a an empty region of the Origin workspace and release the mouse button. Notice that the New Project button is removed from the Standard Toolbar.

To add a button to an Origin toolbar:

  1. Click on the Button Groups tab of the Customize Toolbar dialog.

  2. Select Standard in the toolbar Groups list. Note that the Standard toolbar buttons appear to the right under the Buttons heading.

  3. Place your cursor over the New Project button [image] and drag the button icon back to the first position on the Standard toolbar. The complete Standard toolbar looks like this:

As you become more familiar with Origin, you may decide to create your own toolbars using just the buttons that you use most, or you may wish to take it a step further and create your own bitmaps and buttons that perform custom routines. To find out more about Origin toolbars, select Help:Origin and search on keyword toolbars.


Project Explorer

Typically, users amass quite a lot of data in an Origin project file. If you anticipate building a project file that contains dozens of worksheets, graphs, notes windows, etc., you will probably want to use Project Explorer to help you manage your Origin workspace. Project Explorer helps to organize your workspace so that you see only data that is relevant to the task at hand. In addition, you can use Project Explorer to create new project files from a portion of an existing project file or to append the contents of another project file to your current file. The Project Explorer workspace can be hidden or restored as needed.

To display the Project Explorer workspace:

  1. If you are continuing from a previous session, click the New Project button [image] on the Standard toolbar. You do not need to save anything from a previous tutorial session.

  2. If the Project Explorer workspace is not open, press ALT + 1, or click on the Project Explorer toolbar button [image].

The Origin workspace should only have a single worksheet named Data1. The Project Explorer window will display at the bottom of the Origin workspace and should look something like this:

The left hand window shows a single folder entitled “Untitled.” This is your as-yet-unnamed Origin project file. The right hand window displays the contents of your project file – at this point, a single worksheet entitled Data1.

  3. Add another Origin worksheet by clicking on the New Worksheet button [image] on the Standard toolbar.

Note: The New Worksheet button performs the same operation as selecting File:New…Worksheet from the menu.

Your unnamed project file should now contain two worksheets and both should display as icons in the Project Explorer workspace.

  4. Click the New Graph button [image] on the Standard toolbar.

  5. Click the New Graph button once more. You should now have two worksheets and two graphs in the untitled project file.

Obviously, adding many new worksheets and graphs to the project would, in time, make it difficult to find what you are looking for. To help manage your project files, you might create subfolders within the Origin project file. Let’s create two subfolders – one for worksheets and one for graphs – and put the empty worksheets and graphs that we have opened into the appropriate folder.

To add a subfolder to the project using the Project Explorer interface.

  1. Right-click on the Untitled folder icon in the left-hand pane of the Project Explorer workspace. A shortcut menu opens.

  2. Select New Folder from the shortcut menu.

  3. A new folder opens in the right hand pane of Project Explorer. You can rename this folder at this time. We'll name it Worksheets.

  4. Once again, right-click on the Untitled folder icon in the left-hand pane of the Project Explorer workspace.

  5. Again, select New Folder from the shortcut menu and rename it Graphs.

Your Project Explorer workspace should now look something like this.

  6. Hold down the CTRL key and select Data1 and Data2 from the right-hand pane. When you have selected both of them, hold down your left mouse button and drag the two window icons to the Worksheets subfolder on the left side of the workspace.

  7. Hold down the CTRL key, select Graph1 and Graph2, and drag the two graph window icons to the Graphs subfolder.

Your worksheets and graphs are now in two separate subfolders. How you organize your Origin project files is, of course, entirely up to you, and will depend on your needs and your work style. Suppose that we wanted to save just the contents of the Graphs subfolder as a separate file?

To save a project subfolder as a separate file:

  1. Click on the Graphs subfolder in the left-hand pane, right-click and choose Save Project As…from the shortcut menu. Origin’s Save As dialog opens prompting you for a name and destination directory. You do not need to save this file.

  2. Choose Cancel.

On occasion, you may also find it helpful to hide certain windows, so that they are not visible in the Origin workspace These may be worksheets of questionable data or the results of something that you tried that didn't work out. Rather than delete these windows, you may prefer to simply hide them.

To hide or show a window in Origin using the Project Explorer:

  1. Select the Graphs subfolder in the left-hand pane of the Project Explorer workspace. Your two graph windows should be visible in the Origin workspace. Notice also, that two window icons – Graph1 and Graph2 – appear in the right hand pane of Project Explorer.

  2. Click the Close button [image] in the upper right hand corner of Graph1. An attention box asks whether you wish to hide or delete Graph1.

  3. Choose Hide. Notice that Graph2 disappears from the Origin workspace. Notice also that, although the Graph2 icon is still visible in the right-hand pane of Project Explorer, it is a bit “washed out” looking. This is a visual cue as to the hidden status of this window.

  4. Double-click on the Graph1 icon in the right hand side of Project Explorer. The graph window is restored and the window icon now looks “normal.”

  5. Double-click again on the Graph1 window icon in the right-hand pane of Project Explorer. The window is again hidden.

Thus, you see that there are a couple of ways that you can show or hide windows in the Origin workspace.

The last part of this exercise is simply a short lesson in manipulating the position of the Project Explorer workspace. The default state for Project Explorer is docked at the bottom of the Origin workspace. However, this can be altered, as needed.

To undock and dock the Project Explorer workspace:

  1. To undock Project Explorer, double-click on the two vertical bars on the left side of the Project Explorer workspace.

  2. To return the Project Explorer workspace to it’s docked position, double-click on the workspace title bar.

In terms of default position, the Project Explorer workspace behaves as do Origin toolbars. When you exit the program, the existing position and state (docked or undocked) of toolbars or of the Project Explorer workspace are stored as the default.

This concludes the Origin Workspace tutorial.


Tutorial 2, Worksheets, Data Import, and Plotting

The worksheet is Origin’s primary data storage structure.

In this tutorial, you will import a sample dataset into an Origin worksheet and format the worksheet to control the way that the data are plotted. Then, you will create a line and symbol graph from the imported data.


The Origin Worksheet

The Origin worksheet looks superficially like a spreadsheet. However, it differs from a spreadsheet in some key respects:

  • When working with spreadsheets, you typically refer to data points by intersecting row and column designations. In Origin, a worksheet column or dataset defines the primary data grouping while index (row) numbers serve to define a secondary grouping.

  • While it is certainly possible to programmatically read and write to a single Origin worksheet “cell,” a worksheet “cell” cannot be made to store a mathematical formula that refers to the value contained in another cell in the same column as one might do with a spreadsheet (Note, however, that Origin does have a similar feature that allows you to create a data set -- a column of data -- by defining a function that references the values in other data sets in the Origin workspace).

We will begin this tutorial by importing some sample data. Origin imports data stored in a wide variety of formats, and it will import very large files (more than 1 million lines of ASCII data) relatively quickly. These various file format import options are available from the worksheet's File:Import submenu.

  1. Click the New Project button [image] on the Standard toolbar. You do not need to save the results of the previous tutorial session. A new project file will open containing a single worksheet named Data1.

  2. From the menu, choose File: Import…: Import Wizard…. The Import Wizard opens. There will be a slight delay if this is the first time you have opened the wizard as Origin must first compile some files required for the wizard to operate.

  3. Click on the browse button [image] next to the File edit box and navigate to the file Tutorial_1.DAT under the Origin\Tutorial folder.

  4. Select the Rename Worksheet to File Name check box.

  5. Clear the Set Worksheet Label to File Name check box.

  6. Leave the Import Filter for Current Data Type drop-down list at the bottom of this page on <none> and click the Next button.

  7. You will now be on the Header Lines page. On this page, verify that...

    Number of Header Lines     is set to 2.
    Column Names From Line     is set to 1.
    Column Label Lines     is set to 1 to 2.
    Save Header Lines     is set to 1 to 2.

  8. Click the Finish button to import the file. You should now see a tutorial1 worksheet display as below: (you may need to resize the worksheet to see all columns)

Notice that the worksheet is renamed using the name of the ASCII file that you imported. Recall that Origin does not allow special characters in window names so the underscore is dropped.

Note: The Import Wizard has many other settings for customizing the import of complex ASCII files, as well as features such as extracting variables from header lines etc. The Wizard is also capable of importing simple binary files, and also for supporting user-defined import code written in Origin C. The Wizard allows users to save settings in Filter files that can be re-used to quickly import similar files in the future, without having to repeatedly specify import options.

In addition to using the Wizard for importing files, you can drag-and-drop your file onto the Origin interface, or use the “Import ASCII” toolbar buttons located in the Standard toolbar.

Origin also supports import of many other file types such as such as ThermoGalactic SPC, Minitab etc. These file can be imported by either using the File:Import menu or by drag-and-drop.

When performing drag-and-drop, if Origin is minimized, drag the file to the Taskbar program icon and hold it there until the program workspace is restored. Then drop the file onto a worksheet, graph window, or an area outside the window.


Designating Worksheet Columns as Error Bars

When you import data into a worksheet, Origin’s default behavior is to designate the leftmost worksheet column as an X column and all columns to the right as Y columns. These X and Y designations are important because they determine the way that Origin will treat the data when they are plotted.

In this case, the Time column is designated as X and the Testn and Errorn columns are designated as Y columns. In this worksheet the Errorn columns are intended to be error measurements. Further, the Error1 dataset is associated with the to Test1 dataset, the Error2 dataset is associated with the Test2 dataset, and so on. Column designations should be (from left to right) X, Y1, Y1 Error, Y2, Y2 Error, Y3, Y3 Error.

To specify the plot designation:

  1. Position the cursor over the column heading labeled Error1(Y) and double-click with your mouse. The Worksheet Column Format dialog box for that column (data set) opens (You can also open this dialog box by highlighting a column and choosing Format:Column from the Origin menu).

  2. In the Options group, select Y Error from the Plot Designation drop-down list.

  3. Click the [image] button at the top of the dialog.

  4. The Test2 column is properly designated as a Y column so we will skip to the next column.

  5. Click the [image] button.

  6. To designate Error2 as an error column, choose Y Error from the Plot Designation drop down list.

  7. The Test3 column is properly designated as a Y column, so we will skip to the next column.

  8. Click the [image] button and designate Error3 as a Y Error dataset and then click OK.

The worksheet should now look like this:

Note: Column designations can be set using the Import Wizard pages so that the columns are set to desired designations when the file is imported into the worksheet. In this tutorial, we chose not to set the designations using the wizard, but to set them manually from the interface.

Also, rather than setting the plot designation of each column manually, in this case, we could have set the designations by selecting the entire worksheet (as illustrated below), right-clicking on the worksheet, and selecting Set As: XYYErr from the shortcut menu.


Plotting Your Data

For most 2D and some 3D graph types, creating a graph is a simple, two-step process: (1) select your worksheet data and (2) click on a button on one of the plotting toolbars.

When you select and plot multiple datasets using this technique, Origin automatically groups the data plots and increments attributes such as the symbol type and color by dataset, so as to visually distinguish individual plots.

The tutorial 1 worksheet should look like this:

  1. Position your cursor in the upper left corner of the worksheet. When the cursor changes to a downward pointing arrow, left-click once to select the entire worksheet.

  2. Click the Line+Symbol graph button [image] on the 2D Graphs toolbar.

The data are plotted as a Line + Symbol plot, and the Error datasets are plotted as Y Error bars on the Test1, Test2, and Test3 data plots, respectively.


Focusing on a Region of Your Graph

You may want to take a closer look at some portion of your plot(s), particularly if your plots are composed of large numbers of data points. Origin provides several tools to accomplish this, including the Enlarger tool. The Enlarger tool automatically rescales the axes of the graph to show only the region of the data plot(s) you select.

To enlarge a region of your data plots using the Enlarger tool:

  1. Click the Zoom In button [image] on the Tools toolbar.

  2. Using the magnifying glass cursor, hold down the left mouse button and drag a box around the large peaks (near X = 1.5) in the graph window. Release the mouse button to complete the operation.

Note: If the Enlarger tool button is not visible, you may need to make the Tools toolbar visible. To show or hide an Origin toolbar:

1. Select View:Toolbars… from the main menu.
2. Select the Toolbars tab of the Customize Toolbars dialog.
3. Check to show -- or uncheck to hide -- a toolbar.

Your graph should now look something like this:

  3. To replot the data over the entire range of X values, click the Zoom Out button [image] on the Tools toolbar.


Customizing Grouped Data Plots

The flexibility to customize virtually every graphic element is one of the cornerstones of Origin’s power. You can easily change the appearance of most graphic elements by pointing to that element and double-clicking with your mouse.

For most graphic elements, customizations are made from the Plot Details dialog box. This tabbed dialog allows you to customize every aspect of your graph with the exception of graph axes and text labels. Using the Apply button, you can readily see how your changes will affect the appearance of your graph, without having to repeatedly reopen the dialog box.

Note: Once a graph is customized, you can save the customization as a (graph) Template file, or you can save the settings as a Theme file, and recall them for future use. To learn more, please refer to the Themes and Templates tutorials in this collection.

As you look at the Plot Details dialog box, you can see that it is divided into two main parts:

  • The left pane provides a hierarchical view of the graph’s primary elements:
    Graph > Layer(s) > Data set(s)> Data Points/Error Bars/Data Labels    .

  • The right pane contains one or more tabs that provide access to the format options available for the element -- the page, the layer, the data set, or the data point -- selected in the left-hand pane.

Changing the appearance of grouped data plots

We have already noted that when you select multiple data sets and plot them into a single layer, Origin automatically creates a data plot group, wherein plot attributes (color, symbol shape, fill pattern, etc.) are assigned to each data set by incrementing the members of a list pertinent to each attribute.

For example, looking at the legend that was created for our tutorial plot, we can see that line and symbol color increments in this fashion: data set 1 (Test1) is black, data set 2 (Test 2) is red, and data set 3 (Test 3) is green. Similarly, symbol shape increments in this fashion: data set 1 (Test1) is filled square, data set 2 (Test 2) is filled circle, and data set 3 (Test 3) is filled up-triangle.

To edit grouped data plots...

  1. Double-click the Test1 data plot icon [image] in the graph legend. The Plot Details dialog box opens with the tutorial1: Time(X), Test1(Y) data plot icon selected in the left hand pane.

As the first data set in the data list, Test1 controls the plot attributes of the two other Y data sets in the group -- Test2 and Test3. The attributes of plots Test2 and Test3 are assigned by incrementing the relevant list (color, symbol shape, etc.) following the style that is applied to the first data set in the group.

Now, look to the right side of the dialog box (the Group tab) and note a couple of things:

  • The Dependent radio button is selected indicating the aforementioned plot attribute dependency.

  • Group Members provides a preview of plot appearance.

  • Check boxes in the Increment column indicate that Line Color and Symbol Type are set to increment, but Line Style and Symbol Interior do not. We can see that this is true as Line Style is solid and Symbol Interior is filled for all three data sets; these attributes do not increment.

  2. Click once at the right side of the color bar in the Details column and a "browse" button [image] will appear.

  3. Click once on the browse button and open the color list dialog box.

  4. Rearrange the color list by dragging the ordering number at the left side of this dialog box, so that it looks like this:

  5. Select the Symbol tab on the right side of the Plot Details dialog box.

  6. Click OK. Note that our Group Members list now looks like this:

  7. Clear the Increment, Symbol Type check box, select the Line Style check box, and click OK. The Group Members now look like this:

We no longer increment symbol type by data set, but line style is incremented by data set according the order -- solid, dashed, dotted, etc. -- in the line style increment list (To view the line style increment list, point to the right edge of the symbol bar in the Details column and click once; click on the browse button that appears, to open the symbol list dialog box).

There is much more that can be done with the Group Incremental Lists. You can rearrange and delete members of any list and save the resulting list (or lists) with the graph template (.OTP file). Alternately, you could save the resulting list(s) as a Theme (.OTH file), in which case you could apply the theme to other graphs -- regardless of the template used in their creation -- giving your graphs a new look.

To learn more, go to Index keyword Group Incremental List at (from the Origin menu) Help:Origin. Also, be sure to work through the tutorials on Themes and Templates, included in this document.


Customizing the Graph Axes

To customize the graph axes using the Axis dialog box:

  1. Double-click on the X axis. The Axis dialog opens.

Note: If you double-click on the axis itself, the Axis dialog opens to the Scale tab. If you double-click on the axis label, the Axis dialog opens to the Tick Labels tab. You can also open the Axis dialog by choosing Format:Axes from Origin’s main menu.

  2. On the Scale tab, type 1.2 in the From text box, 1.8 in the To text box, and 0.1 in the Increment text box.

  3. Select the Title & Format tab.

  4. Type Time (sec) in the Title text box, overwriting the default text (We could just as well edit the axis title directly in the graph, but since we are working in this dialog box, we will do it this way).

  5. Select the Left icon [image] from the Selection list box.

  6. Type Potential (mV) in the Title text box, overwriting the default text.

  7. Select the Scale tab.

  8. Type -.001 in the From text box, .014 in the To text box, and .002 in the Increment text box.

  9. Click OK.

Your graph should now look something like this:


Adding Text to the Graph

To further customize your graph, you can add annotations including text, arrows, lines, and shapes. The tools for adding these annotations are located on the Tools toolbar. Alternatively, you can right-click anywhere in the graph to Add Text using a shortcut menu.

  1. First click and drag the legend so that it is located close to the Y axis. Click outside the legend to de-select it.

  2. Click the Text tool button [image] on the Tools toolbar and then click in a blank area in the upper-left corner of the graph. A text label is created. You will see the cursor flashing at the text entry point.

  3. Type Effect of Solvent Loss on Sample Potential in the text label. When you are done, click once outside the text label, or press ESC, to exit the text edit mode.

  4. Click once on the new text label so that it becomes selected.

  5. Drag the bottom right control handle to increase the size of the label. The control handles are the small, black squares surrounding the text label.

  6. When finished resizing, click outside the label to de-select it.

  7. Click the Date & Time button [image] on the Graph toolbar to add a date and time stamp.


Saving Your Project

Your project currently consists of one worksheet and one graph window and the data displayed in both. Both of these windows and the data they contain are stored within the Origin project file when you save the project

  1. Click the Save button [image] on the Standard toolbar.

  2. Type Tutorial_1 in the File name text box, then click Save. The project is saved as Tutorial_1.OPJ. Note the path to the saved file.

This concludes the tutorial on Worksheets, Data Import, and Plotting.


Tutorial 3, The Import Wizard.

In this tutorial, you will import an ASCII data file using the Import Wizard and in the process create a custom import filter for importing similar files in the future. You will also extract information from the header section of the ASCII file, and then use the extracted information to create a custom label on a graph.


Selecting a File to Import

  1. Click the New Project button [image] on the Standard toolbar. You do not need to save the results of the previous tutorial session. A new project file will open with a Data1 worksheet active.

  2. Select File: Import:Import Wizard…. The Import Wizard opens.

Note: If this is the first time you are starting the Import Wizard, there may be a slight delay caused by Origin compiling files associated with the wizard.

  3. Make sure the ASCII radio button is selected in the Data Type group.

  4. Click the browse button [image] next to the File text box, and navigate to the file Tutorial_ASCII.DAT under the Origin\Tutorial folder. Select this file, and then click the Open button.

  5. Leave the Rename Worksheet to File Name check box cleared, and the Set Worksheet Label to File Name check box selected.

  6. Leave the Import Filters for Current Data Type drop-down list at the bottom of this page set to <none>, and click the Next button.


Customizing the Import Settings

You are now on the Header Lines page of the Import Wizard. The Header Lines page contains options for customizing how lines of the data file are interpreted. Origin makes assumptions and creates defaults based on the data file format which you can change in the list boxes at the top of the page.

  1. On this page, make sure the drop-down lists have the following settings:

    Number of Header Lines     = 8
    Column Names From Line     = 7
    Column Label Lines     = 7 to 8
    Save Header Lines     = 1 to 8

    A preview of the ASCII file is shown below the drop-down lists, and the header lines are colored according to the drop-down settings. Make sure the Define Header Variables checkbox is checked.

  2. Click the Next button to continue to the Header Variables page.

  3. Select Colon(:) from the Delimiter drop-down list, then click the Scan button.

The variable list in the lower half of the page will update to show the variables and their string values, from the header section. These variables will be saved in the worksheet when import is completed. We will use them to label a graph later in this tutorial.

  4. Click the Next button three times to arrive at the Save Filters page. On this page, we will save our current settings to an Origin Import Filter File (*.OIF).


Saving the Options as a Filter

Origin Import Filter Files (*.OIF) allow you to save the settings from the Import Wizard so that you can import this file (or similar files) in the future without having to specify all the import settings each time.

To save the settings from this session as a filter:

  1. Select the Save Filter check box.

  2. Select the In the User Files Folder radio button on this page. The filter file will be saved in a default Filters subfolder in the User Files area.

  3. In the Filter Name text box, enter Tutorial for the name of the filter.

  4. In the Wildcards text box, enter Tutorial*.dat.

  5. Leave the Specify Advanced Filter Options checkbox cleared, and click Finish. The ASCII file will now be imported into the Data1 worksheet, which should look like the following figure: (Note: the column widths have been increased to show the entire label).

Notice that the file name has been assigned to the worksheet label, which is now displayed on the title bar of the worksheet page. Also, notice that the column labels have the entire column name with spaces (such as “ST Potential”) whereas the spaces have been removed from the column name (such as STPotential). Special characters (such as spaces) are not allowed in column names. Furthermore, column labels can be longer than column names.


Using the Header Data to Create a Custom Label

Now that the data file has been imported we will illustrate the utility of the ASCII file header. We will create a graph and label the graph using information extracted from the header section of the ASCII file.

  1. Highlight all columns of the worksheet by placing the cursor on the white rectangle at the top left corner of the worksheet and then clicking the left mouse button when the cursor changes to a down arrow.

  2. Select Plot:Panel:Stack. This will create a graph with 4 layers and will plot all the Y columns from the worksheet in those four layers. The column label information will be used in the left axis labels for each layer.

  3. Click the Text Tool button [image] on the Tools toolbar, and then click on the area on top of the graph. This allows you to create a text label on the graph and by default, will place you in the in-place text editing mode.

  4. While in the in-place text editing mode, press CTRL + H. This will open the Insert UserInfo Variables dialog box. The variables extracted from the ASCII file header will all be listed in this dialog, along with information such as file name, file path etc.

  5. Hold the SHIFT key down, and select the user variables Measurement Type, Measurement Title, and Acquisition Date.

  6. Click the Insert button to close the dialog and insert all three variable values into the text object.

With some minor edit changes such as making this new label a multi-line centered text, your graph should like the following:


Using the Import Filter

We will now re-import the same data file using the import filter we created earlier in this tutorial.

To Import an ASCII file using a filter:

  1. Start a new project by clicking on the New Project [image] button. You don’t have to save the existing project.

  2. With the Data1 worksheet active, select the menu item File:Import:Import Wizard….

  3. Click the browse button [image] next to the File Name edit box and navigate to the file Tutorial_ASCII.DAT in the Origin\Tutorials folder. Select this file and click Open.

  4. At the bottom of this page of the wizard, select the List Files Applicable to Both Data Type and File Name check box. From the Import Filters For Data Type drop-down list, select User: Tutorial. This is the category and name of the import filter file that we saved earlier.

  5. Click the Finish button to complete the import process.

  6. The Data1 worksheet should now have the same content as it had in the previous section of this tutorial.

Origin Import filter files also support drag-and-drop operation.

To use drag-and drop, perform the following:

  1. Start a new project by clicking on the New Project [image] button. You don’t have to save the existing project.

  2. Open Windows Explorer and locate the subfolder \Tutorial under the Origin installation folder.

  3. Click on the file Tutorial_ASCII.DAT., hold the left mouse button down, and then drag-and-drop the file onto the Origin interface. If Origin is minimized, hold the file over the Origin task bar icon, wait for Origin to maximize, and then drop the file (release the mouse button) on the Origin interface. This should immediately result in the file being imported into Origin. Note that if you drop the file onto an existing worksheet, the data is imported into that worksheet. If you drop the file onto the gray area, a new worksheet is created.

Defining a filter with a wild card specification also results in a new entry in the File:Open menu.

  4. Select File:Open. This opens the File Open dialog box.

  5. Click on the Files of Type drop-down list. You will see an entry that reads:
    Tutorial(Tutorial*.dat)

  6. Select this entry, navigate to the Tutorial_ASCII.dat file, and double-click on the file to import it. The file gets imported into a new worksheet.

This concludes the Import Wizard tutorial.


Tutorial 4, The Plot Setup Dialog Box

In this tutorial, we introduce the new Plot Setup dialog box. The Plot Setup dialog box provides a flexible interface for adding or removing data sets from your graph windows. You can add or remove any data set in the Origin project to your graph and you can do so without the need to change the column Plot Designations that control how the data plot in the graph (as X, Y, error bar, label, etc.). Additionally, you can specify the plot type and data range using Plot Setup dialog box controls.

The Plot Setup dialog box opens under these circumstances:

  • You click a graph toolbar button or select a plot from the plot menu, without selecting any data.

  • You right-click on the graph window layer icon and select Plot Setup… from the shortcut menu.

  • With a graph window active, you select the Graph:Add Plot to Layer menu item.

In this tutorial, we will utilize this dialog box for creating a new plot starting with a fresh graph template, for editing data plot contents of an existing graph window, and for creating a graph with data from multiple worksheets.


Creating a New Graph

In this section, we will see how the Plot Setup dialog box can be used to create a new graph starting from a fresh graph template.

  1. Open the project \Tutorial\Tutorial_Plot_Setup.OPJ.

  2. From the menu, choose Plot:Template Library. This opens the Template Library dialog box.

  3. From the Category list, choose Special Line & Symbol. From the Template list, choose Doubley. The Preview pane shows a sample "double Y" (two Y axes) plot.

  4. Click the Plot button. This opens the Plot Setup dialog box.

  5. There are three panels in this dialog box. All three should be visible at this point. If they are not, then use the [image] and [image] buttons to display all three panels.

  6. In the top-most panel, click and highlight the row that corresponds to Data1 worksheet.

  7. In the bottom panel, you will see two layers corresponding to the two layers in the DoubleY graph template that we opened. Click on Layer1 to select it. This layer has one plot style holder. We will now fill this style holder with a data plot.

  8. Go to the middle panel, select the box under column X, in the row which has Time in the Column (Name) column; select the box under column Y on the row that has STPotential as Column (Name). Click the Add button to add this data plot to Layer 1 in the panel below.

  9. Now click and select Layer 2 in the bottom panel. In the middle panel, under the Y column, clear the current check box and select the box corresponding to the row with SVPotential as Column (Name). Click the Add button to add this new data plot to Layer 2.

  10. Make sure the Rescale check boxes for each layer are checked, then click the OK button. This will close the dialog box and create a new graph.


Editing an Existing Graph

This section will show how to edit/re-configure an existing graph using the Plot Setup dialog. We will continue from where we left the project in the previous section.

  11. Click the graph page Graph1 that was created in the previous section of this tutorial.

  12. Double-click on one of the layer icons in the top left corner of the graph. This reopens the Plot Setup dialog.

  13. In the bottom panel, select the data plot named Time(X), SVPotential(Y), under Layer 2. This action updates the middle panel of the dialog with the column designations information corresponding to this data plot.

  14. Change the Y association by clearing the check box under the Y column and selecting the check box on the row with STPressure as Column (Name). Click the Replace button. This replaces the data plot in Layer 2 with a new plot as specified in this middle panel.

  15. Make sure the Rescale check boxes are checked, then click OK to close the dialog. The graph is then updated with the change you made to the data plot in Layer 2.


Plotting From Multiple Worksheets

This section will show how to create a new plot by selecting data from multiple worksheets. We will continue from where we left off in the previous section.

  16. Click on (any) one of the worksheets in the current project, then from the menu select the menu item Plot:Panel:Vertical Two Panel. The Plot Setup dialog reopens. Make sure all three panels are visible.

  17. In the top panel, you will see three worksheets. As you select each of the three worksheets, the middle panel is updated with column (data set) information pertinent to that worksheet.

  18. Click on the Label column heading in the top panel. This sorts the list of worksheets in that panel. You can thus sort this list on any column. Drag your mouse over the three worksheet names to select all three (you can also use SHIFT or CTRL + select, as in Windows Explorer).

  19. Once you select all three worksheets in the top panel, the middle panel displays all columns that are common to the three worksheets. In this project, all three worksheets have the same columns, and so all columns are displayed.

  20. Select the X box on the row named Time, and the Y boxes on the row named STPotential.

  21. Make sure the Layer 1 row in the lower panel is highlighted, and then click the Add button. This will then add three data plots to this layer, one from each of the worksheets selected in the top panel.

  22. Now make Layer 2 row active in the lower panel, select STPressure in the middle panel, and click the Add button to add three data plots to Layer 2.

  23. Hold down the SHIFT key, select all three plots added under Layer2 in the bottom panel, then right-click and select Group. This groups the three data plots in that layer. Repeat this grouping procedure for Layer 1.

  24. Make sure the Rescale check boxes are selected and click OK to create the graph.

This concludes the Plot Setup dialog box tutorial.


Tutorial 5, Working with Excel in Origin

You can open Excel workbooks directly in Origin, provided you have Excel 7 or later installed on your computer. This allows you to combine Excel’s spreadsheet tools with Origin’s powerful graphing and analysis tools.

This tutorial will show you how to open Excel workbooks in Origin, plot your Excel data using Origin graph templates, then save your Excel workbooks from Origin.


Opening an Excel Workbook in Origin

To follow this tutorial, you must have Excel version 7 or later installed on your computer, either as a local or network copy.

To open an existing Excel workbook:

  1. On the Standard toolbar, click the New Project button [image].

  2. On the Standard toolbar, click the Open Excel button [image].

  3. In the Origin \Tutorial folder, select Tutorial_7.XLS from the file list.

  4. Click Open.

The Open Excel dialog box opens. This dialog box gives you the choice of opening your Excel workbook (in Origin) as a workbook or opening it as an Origin worksheet. If you open a workbook as a workbook, you have access to Excel menus and toolbars, but somewhat restricted use of Origin’s analysis and graphing features. If you open the workbook as an Origin worksheet, you have full access to Origin’s graphing and analysis features, but you will not have access to Excel’s spreadsheet features.

Note: The workbook/worksheet choice isn’t entirely an “either/or” situation. You can open an Excel file twice – once as a workbook and a second time as a worksheet – and have access to everything that both programs have to offer. You can also copy and paste data from an Excel workbook into an Origin worksheet.

  5. Select the Open As Excel Workbook radio button.

  6. Click OK.

The workbook opens in the Origin workspace. Notice that a combination of Origin and Excel menus and toolbars are now displayed in the workspace.


Plotting an Excel Workbook in Origin

Plotting Excel workbook data in Origin is very similar to plotting Origin worksheet data. If a graph window is open, you can drag and drop data from a workbook into the graph window.

You can also create a new graph from your workbook data by (1) activating your workbook and (2) clicking a button on one of the plotting toolbars or by selecting a graph type from the Plot menu. An intermediary Select Data for Plotting dialog box opens to allow you to assign data sets to the graph.

By default, the Select Data for Plotting dialog box opens when you select your Excel data and click a button or select a menu command to plot the data. After you become familiar with Origin's graph templates, you may be able to bypass this dialog box and plot your data directly from the workbook.

To bypass the Select Data for Plotting dialog box, open the Options dialog box (when a workbook is active, select Window:Origin Options; When any other window type is active, select Tools:Options) and select the Excel tab. Then, in the Plotting Selection Group, select the Default Plot Assignments check box.


Creating a Graph Using the Select Data for Plotting Dialog Box

The Select Data for Plotting dialog box lets you select data and then assign plotting designations.

To create a graph using the Select Data for Plotting dialog box:

  1. Click the Column button [image] on the 2D Graphs toolbar. This opens the Select Data for Plotting dialog box.

  2. Reposition the dialog box so that you can see the column headings in the Excel workbook.

  3. Click the column A heading in the workbook, then click [image] in the Select Data for Plotting dialog box.

  4. Click the column C heading, then CTRL+Click on the column F heading and then click [image] in the Select Data for Plotting dialog box.

The box below the buttons indicates data ranges by plot designation. X:A1:A65536 means that the X data is being represented by column A, rows 1 to 65536. The last row number of the column is shown because you selected the whole column.

  5. Click the Plot button in the Select Data for Plotting dialog box, then click Close.

  6. Reposition the legend on the graph page.

When the graph window is active, you may notice a blank gray area in the toolbar region. This is called a toolbar spacer. The toolbar spacer is reserving space for the Excel toolbars, which will display when you re-activate the Excel workbook. If desired, you can hide the toolbar spacer by right-clicking in the spacer and selecting Hide Toolbar Spacer from the shortcut menu. When you re-activate the workbook, Origin will automatically display the spacer with the Excel toolbars.


Creating a Data Plot by Dragging Data Into a Graph

When you drag Excel workbook data onto an Origin graph, Origin makes assumptions about the plotting designations of the selected data.

  • If one column (or a range from one column) is highlighted, then this column supplies the Y values for the data plot. The data is plotted versus row number.

  • If more than one column (or a range from more than one column) is highlighted, the leftmost column supplies the X values. All other columns supply the Y values. The data is plotted versus the X values.

  • If more than one column (or range from more than one column) is highlighted and the CTRL key is depressed while dragging the data, then all the columns supply the Y values. The data is plotted versus row number.

To create a graph using the drag-and-drop method:

  1. Click the New Graph button [image] on the Standard toolbar. Reposition/resize the Graph2 window so that when the workbook is active, it doesn’t completely hide the new graph window.

  2. Select Window:Book1 to activate the Excel workbook window.

  3. Highlight the first two columns in the workbook. Note that as you move your mouse over the right edge of your two columns of selected data, the cursor changes.

  4. Point to the right edge of the B column and, when the cursor becomes a pointer, hold down the left mouse button and drag the data to the Graph2 window. When you release the mouse button, column B is plotted against column A as a line plot in the graph window.

  5. Click on the graph window to make it the active window.


Creating a Graph Using Origin’s Default Plot Assignments

This plotting method allows you to select your workbook data and graph type, and then Origin creates the data plots by making assumptions about the plotting assignments of the selected data. This plotting method is not available by default. It must be activated from the Options dialog box (Window:Origin Options when a workbook is active; Tools:Options when an Origin window is active).

To create a graph using Default Plot Assignments:

  1. Select Tools:Options to open the Options dialog box. (If the workbook is active, then select Window:Origin Options).

  2. On the Excel tab, select the Default Plot Assignments check box.

  3. Click OK, then click No (no need to save as a start up option) to the dialog box that opens.

  4. Make the Excel workbook active.

  5. Click on the column A heading, then CTRL+ select column D and G headings.

  6. Click the Area graph button [image] on the 2D Graphs toolbar.

  7. Reposition the graph legend.


Saving an Excel Workbook in Origin

There are two ways to save Excel workbooks with your Origin projects. You can save the workbook internal to the project, which means that it is saved as part of the Origin project and can only be opened by opening the Origin project file.

The other choice is to save the workbook as external to the Origin project file. When you save a workbook externally, a link to the workbook is maintained in the project file.

The chief advantage to storing your workbook internally is that all of your graphs, analyses, support data, etc., can be bundled together in a single file. This makes it easy to share data with other Origin users.

Of course, sometimes sharing data with colleagues may mean that you are working on a common file that is saved to a shared folder on the your network. In such cases, saving your data to an external Excel workbook file may be the way to go.

Note: Internally saved workbooks do not maintain links with external Excel workbook files. Thus, if you save a workbook internally while colleagues continue to work on the external Excel file, your project workbook will not be updated.

By default, pre-existing workbooks that are opened in an Origin project are saved external to the project, whereas workbooks that are created from within Origin are saved internal to the project. However the save option can be changed in the Workbook Properties dialog box.

To save the workbook internal to the Origin project:

  1. Make the Excel workbook active.

  2. Right-click on the title bar of the workbook and select Properties from the shortcut menu. This opens the Workbook Properties dialog box.

  3. Select the Internal radio button in the Save As group.

  4. Click OK.

  5. Select File:Save Project As.

  6. Type Excel_Tutorial in the File Name text box.

  7. Click Save.

The project is saved and the workbook is saved internal to the project. Any changes that you now make to the Excel workbook located in the \TUTORIAL folder will not be reflected in the project file the next time it is opened.

This concludes the Excel tutorial.


Tutorial 6, Exploring your Data

Origin offers a number of data selection tools to aid in exploring and analyzing your data; these include the Data Reader, Screen Reader, Data Selector, Enlarger, Zoom, Region of Interest and the various data masking tools available from the Mask toolbar. To learn more about these features, consult the Origin help file at Help:Origin….

In this tutorial, you will use the masking tools to selectively exclude unwanted data points from your analyses. You will also mathematically transform some worksheet data, do a primary and secondary sort of some worksheet data, plot a range of data and perform a quick linear fit on a plotted data set.


Importing Data

To begin this tutorial, you will open a new Origin project and import ASCII data. To import an ASCII data file:

To import an ASCII data file:

  1. Click the New Project button [image] on the Standard toolbar.

  2. Click the Import ASCII button [image], then select Tutorial_2.DAT from the Origin \Tutorial folder.

  3. Click Open.

Note: A portion of the worksheet (and the imported data) may not be visible. You may need to use the scroll bars at the bottom and right edges of the worksheet to locate worksheet columns of interest.


Transforming Column Values

You can create or transform datasets with a mathematical expression via the Set Column Values dialog box. This dialog box provides a text box for you to type a value or mathematical expression (or compiled Origin C functions) to apply to an entire column, or portion of a column of worksheet data.

The Set Column Values dialog also includes a function drop-down list from which you can select a function to add to the text box. A column drop-down list contains a list of all columns in the active worksheet. Select the column you want to add to the text box, then click Add Column to add the selected column to the text box.

Note: You can also type column names into the text box, and, in fact, when referring to columns in other project worksheets, you must do so. Refer to columns in the same worksheet using the col(name) notation. Refer to columns in other worksheets using the wksname_colname notation. For example: col(A)=Data1_b*3

To transform a column of values via the Set Column Values dialog box:

  1. We will begin by inserting a column into the Tutorial2 worksheet. Click on the Depth column heading (to the right of the Time column) and choose Edit:Insert from the menu. This inserts an empty column into the worksheet.

  2. Double-click on the new column's heading to open the Worksheet Column Format dialog box.

  3. Change the Column Name to TimeMin and click OK. Your worksheet should now look like this:

  4. Right-click on the TimeMin(Y) column heading, and select Set Column Values… from the shortcut menu. This opens the Set Column Values dialog box.

  5. In the Col(TimeMin)= text box, enter the following expression:

col(Time)/60

  6. Select the AutoUpdate check box and click OK.

The TimeMin(Y) column is filled with values, according to the formula entered in the column's Set Column Values dialog box. Note, too, that column TimeMin is now "locked" -- as indicated by the lock symbol on the column heading. When an AutoUpdate is pending, the lock symbol will appear as a yellow "traffic light" (Unless a number of operations are queued, you may never see the traffic light).

When you select AutoUpdate, as we did, any change to the source data (in this case, the Time column), triggers an execution of the TimeMin column formula and an update of TimeMin column values.

  7. Right-click on the Time(Y) column, select Set Column Values, enter the following expression in the Col(Time)= text box, and click OK:

col(Time)+100

The worksheet now looks as follows. Note the AutoUpdate of the values in column TimeMin(Y):


Sorting Worksheet Data

Origin can sort data in individual columns, multiple columns, or entire worksheets. Origin offers simple sorting in which selected data are sorted using a “sort by” column, in ascending or descending order.

Origin also offers custom sorting of multiple columns, in which sorting is done first on a primary column, while subordinate "sort by" columns are sorted in nested fashion in either ascending or descending order.

To sort worksheet data:

  1. Hold down the CTRL key and select every column in the worksheet except the locked TimeMin(Y) column. This column must be excluded because it's values are dependent upon values in another column.

  2. Click the Sort button [image] on the Worksheet Data toolbar to open the Nested Sort dialog box (If the Worksheet Data toolbar is not displayed, select View:Toolbars and select it from the list).

  3. Select DEPTH from the Selected Columns list box, then click the [image] button. The column is added to the Nested Sort Criteria list box. This selection makes DEPTH the primary column, to be sorted in ascending order.

  4. Select STN from the Selected Columns list box, then click [image]. This makes STN the secondary sort column, to be sorted in ascending order.

  5. Click OK.

The entire worksheet is sorted so that the values in the DEPTH (primary) column are ascending. For duplicate values in the DEPTH column, the values in the corresponding rows of the STN (secondary) column determine how the worksheet data are ordered.

Note: To sort the values in every column in a worksheet in ascending order, you would have to sort columns individually. Otherwise, the worksheet is sorted on the primary column and all values in row ii will still be in a common row after data are sorted.


Plotting a Range of the Worksheet Data

You can delimit your worksheet data so that subsequent plotting and analysis are performed only the selected range.

To select a range of worksheet data:

  1. From the menu, select View:Go To Row.

  2. Type 52 in the GoTo Row dialog box, and click OK.

  3. Right-click on the row heading of row number 52.

  4. Select Set As Begin from the shortcut menu.

  5. Use the vertical scroll bar to move down in the worksheet so that row number 68 is visible.

  6. Right-click on the row heading of row number 68.

  7. Select Set As End from the shortcut menu.

Notice that the data outside the selected range is no longer displayed in the worksheet (excepting the locked TimeMin(Y) column). The data has not been deleted from the worksheet, only hidden to provide for easier viewing of the selected range. To restore the hidden data, select the entire worksheet from the menu, choose Edit:Reset to Full Range.

To plot this subset of data:

  8. Click on the FLUOR(Y) column heading to select the column.

  9. Scroll to the right in the worksheet, hold down the CTRL key and click on the TEMP(Y) column heading. This selects both the TEMP and the FLUOR columns.

Note: To select noncontiguous columns, use CTRL + click. To select a range of contiguous columns, use SHIFT + click.

  10. Click the Double Y Axis button [image] on the 2D Graphs Extended toolbar (or select View:Toolbars if the 2D Graphs Extended toolbar isn't open.).


Masking Data in the Graph

The Mask toolbar provides other means for excluding data from Origin's analysis and fitting routines. You can mask individual data points or a range of data. Once data are masked, you can change the masked data color, hide or show the masked data, swap the masked and unmasked data, and enable or disable masking.

To mask a data point in the graph:

  1. Select View:Toolbars, select Mask from the list of toolbars and then click Close. This opens the mask toolbar.

  2. Click the Mask Point Toggle button [image] on the Mask toolbar. This activates the Data Reader tool.

  3. Move the cursor (it is now a cross-hair) to the Double Y-axis plot that we just created and left-click anywhere on the FLUOR data plot (the black square symbols) in your graph window.

  4. Using the right or left arrows on the keyboard, move the cursor to the data point at X = 34 and Y = .59. The Data Display tool displays the point coordinate values.

  4. Press ENTER or double-click to mask this point.

  5. Click the Change Mask Color button [image] on the Mask toolbar. The color of the masked data point changes to green. If you scroll the worksheet to find the data point that you just masked in the graph, you will see that it now displays with a green background to indicate that this particular data point is masked.

  6. With the graph window active, click the Hide/Show Masked Points button [image] on the Mask toolbar to hide the masked data point. Note that the point is removed from the graph.

  7. Once again, click the Hide/Show Masked Points button [image] on the Mask toolbar . This restores the masked data point to the graph.


Performing a Linear Fit on the FLUOR Data Plot

Masking the data point in the FLUOR data plot excludes that point from analysis and fitting operations. You can, however, disable the mask on the data point, and analyze or fit all the data points in the current selection range.

To perform a linear regression with the data point masked:

  1. Select Analysis:Fit Linear. A “best-fit” line is added to the graph and the Results Log opens to display the fitting results (parameter and error value estimates, R-value, SD, etc.). You can scroll the Results Log to view the results.

  2. Click the Refresh button [image] on the Standard toolbar and reposition the legend so it fits on the page. (remember that the page is the white area within the graph window; anything that laps onto the gray area will not be visible when the graph is printed or exported)

By default, the Results Log shows the results for all curve fitting done in the active Project Explorer folder. To change this default behavior, right-click in the Results Log and select a different reporting option.

Each time a fit is performed, the results are appended to the Results Log. Each entry in the Results Log includes a date/time stamp, the window name, a numeric stamp which is the Julian day, the type of analysis, and the results.

To perform a linear fit with the Mask disabled:

  1. Click the Disable/Enable Masking button [image] on the Mask toolbar. The masked data point changes from green to black.

  2. From the menu, select Analysis:Fit Linear. A second regression line is drawn on the graph.

  3. Verify that the mask is disabled by comparing the two fit results in the Results Log.

To remove the initial regression line from the graph:

  1. Hold down the ALT key and double-click on the Layer 1 icon [image] in the upper-left corner of the graph. This opens the Layer 1 dialog box.

  2. Select linearfit1_tutorial2fluo from the Layer Contents list box.

  3. Click the [image] button to remove linearfit1_tutorial2fluo from the Layer Contents list box.

  4. Click OK to close the dialog box.

  5. To update the legend, click the New Legend button [image] on the Graph toolbar. You may also need to click the Refresh button [image] on the Standard toolbar.


Saving the Project

Your Origin project currently contains your data, worksheets, graph, analysis results and the current folder organization as it shows in Project Explorer.

To save the current Origin project:

  1. From the menu, select File:Save Project.

  2. Type a name in the File Name text box.

  3. Click on the Save button.

This concludes the Exploring Your Data tutorial.


Tutorial 7, Creating Multiple Layer Graphs

The layer is the fundamental building block of Origin graphs. A layer is an Origin object consisting of one set of controlling axes. You may opt to hide or show any or all of the four axes (top X, bottom X, right Y, and left Y) that make up the layer. A layer contains text labels, drawing objects, or data plots, that may be shown or hidden. A graph window must contain at least one layer and may include as many as 80 layers.

This tutorial will introduce you to the graph layer concept. In addition, you will learn about Origin's built-in multiple layer graph templates. You will also learn how to create your own multiple layer graph and save it as a template for later use.


The Graph Layer Concept

There is always one -- and only one -- active layer in a graph window. This active layer is the only layer that is subject to program commands. Data or objects added to a graph can only be added to the active layer.

Unless intentionally hidden, a graph window will have one or more layer icons – one for each layer in the graph window – in the upper left corner of the graph window. The active layer is denoted by a depressed layer icon.

  • To hide the layer icons, select View:Show:Layer Icons.

  • To highlight the axes in the active layer, select View:Show:Active Layer Indicator.

Reminder: Just as there can be only one active layer within a graph window, recall that there can be only one active window within the Origin workspace. Thus, the above actions only affect the active graph window.

You can activate a layer in several ways:

  • Click once on the corresponding layer icon in the upper left corner of the graph window.

  • Click once anywhere within the graph's layer frame.

Note: The layer frame is a reference frame defined dimensionally by the Layer Area settings on the Size/Speed tab at the Layer level of the Plot Details dialog. The graph axes, tick marks, tick labels, attached objects and plotted datasets are drawn in relation to this frame and may extend beyond this frame.

  • Click once on any object (text, axis titles, etc.) that is part of or is attached to the layer.


Opening the Project File

The data for this tutorial is provided in an Origin project file.

To open the Origin project file:

  1. Click the Open button [image] on the Standard toolbar.

  2. In the Origin\Tutorial folder, select Tutorial_3.OPJ from the list of files.

  3. Click Open. A project containing four graph windows and a worksheet opens.

Note: Three graph windows and the worksheet are in a minimized state at the bottom of your Origin workspace.


Origin's Multiple Layer Graph Templates

Origin includes a number of highly useable, built-in, multiple layer graph templates. Putting one of these templates to use is a two step process: (1) first, you select a range of data, then (2) you click a button to plot the selected data into multiple layers in a graph window.

The trick is to become comfortable with the behavior of grouped datasets, the graph layer concept, and the workings of the various multiple layer templates. Once you accomplish this, you will be well on your way to producing visually appealing and highly illustrative multi-layer graphs with just a few clicks of the mouse.

The double Y axis graph template is ideal for plotting data that consists of two or more dependent data sets and a common independent data set. A sample double Y axis graph is currently active in your project.

Note that, unlike the example in our lead-in discussion of the graph layer concept, the layers in this graph are superimposed. This is an important point and one that helps to illustrate the power of Origin’s layer concept. Because layers are constructed independently, you can combine and manipulate them in innumerable ways. This allows a great deal of flexibility in the graph creation process.

Origin’s built-in horizontal 2 panel graph template is ideal for plotting related data that do not share an independent data set. Tutorial_3.OPJ contains an example of a graph made using this template.

  1. Click on the Restore Up icon [image] on the minimized Horizontal2Panel window icon at the bottom of your workspace. The Horizontal2Panel graph should now be visible.

  2. Click on the Restore Up icon [image] on the minimized Layers worksheet at the bottom of your workspace. The Layers worksheet should now be visible.

  3. Select the Pontential1(Y) and Pressure1(Y) columns by holding down your left mouse button and dragging the “+” cursor across both column headings. When both are selected, release the mouse button.

To plot the selected data using Origin’s Horizontal 2 Panel template:

  1. Click the Horizontal 2 Panel button [image] on the 2 D Graphs Extended toolbar.

The resulting graph should look very much like the Horizontal2Panel graph window, minus some text annotations.

  2. Click on the Close icon [image] of the graph window that you just created. You may delete the window.

Origin’s vertical 2 panel graph template provides the same data presentation as the horizontal 2 panel graph template, but in a one column/two row configuration (i.e. the graph panels are stacked one on top of the other).

  3. Click on the Restore Up icon [image] on the minimized Vertical2Panel window icon at the bottom of your workspace. The Vertical2Panel graph should now be visible. Resize/move this window so that you can clearly see the Layers worksheet.

To plot the selected data using Origin’s Vertical 2 Panel template:

  1. Select the Potential1(Y) and Pressure1(Y) columns of the Layers worksheet if they are not selected and click the Vertical 2 Panel button [image] on the 2D Graphs Extended toolbar.

The resulting graph should look very much like the Vertical2Panel graph window, minus some annotations.

  2. Click on the Close icon [image] of the window that you just created. You may delete the window.

When your worksheet includes multiple X columns, Y columns in the worksheet plot against the nearest X column to the left. Though this default behavior can be disregarded by selecting non-contiguous columns with CTRL selection, the default plotting behavior allows you to quickly create graphs from associated XY data sets.

The Layer worksheet contains a second column that should be designated as an X column – this is the Trial2(Y) column – so we will change the plot designation to X so that we can proceed with our last multiple layer template plotting exercise.

To designate a second X column:

  1. Right-click on the Trial2(Y) column heading and select Set As:X from the shortcut menu, or double-click on the column heading and choose X from the Plot Designation drop-down list in the Worksheet Column Format dialog box.

The Trial2 column designation changes to X2 and the columns to the right of it are designated as Y2. In addition, the Trial1 column designation changes to X1 and the columns between Trial1 and Trial2 are designated as Y1. Thus configured, the default behavior is for Y1 columns to plot against the X1 column, Y2 columns to plot against the X2 column, etc.

To create a multiple layer graph using the 4 Panel template:

  1. Select the entire worksheet by placing the cursor in the upper left corner of the worksheet. When the cursor becomes a downward pointing arrow, left-click once.

  2. Click on the 4 Panel button [image] on the 2D Graphs Extended toolbar.

Your 4 layer, 4 panel graph should look something like this:


Creating Your Own Multiple Layer Graph Template

Obviously, Origin could not contain pre-defined templates for all the different ways in which layers can be arranged. However, you can create your own custom multiple layer graph and save it as a template for future use.

This segment of the tutorial describes a method for creating a multiple layer graph, using a single layer graph as a starting point. This information is provided to familiarize you with important layer concepts. However, keep in mind that you use any of Origin’s multiple layer graph templates as a starting point for your custom multiple layer graph.

To begin this portion of the tutorial:

  1. Click on the Potential1(Y1) column heading in the Layers worksheet.

  2. Click the Line graph button [image] on the 2D Graphs toolbar.

  3. From the menu, select Tools:Layer to open the Layer tool.

Note: Make a mental note as to where to find this tool. As the tool’s tab names imply, it is very useful for adding and arranging layers in multiple layer graphs. This tool is available only when a graph window is active.

  4. On the Add tab, click the Linked Right Y button [image]. This adds a second layer to the graph.

By default, the X axis of this new layer (layer 2) is linked to the X axis of layer 1. This means that if you change the X axis scale in layer 1, the X axis scale in layer 2 will change simultaneously. Linking is controlled by settings on the Link Axis Scales tab (Layer level) of the Plot Details dialog box.

  5. Double-click on the layer 2 icon in the upper-left corner of the graph window.

This opens the Layer dialog box. What you see to the left side of this dialog is list of all Y datasets in the current project. Note that no datasets are currently listed in the Layer Contents list box. We have added a second layer to our graph, but we have not added any data to the layer.

  6. Select layers_pressure1 in the Available Data list box.

  7. Click the [image] button to add the layers_pressure1 data set to the Layer Contents list box.

  8. Click Layer Properties. The Plot Details dialog box opens.

  9. Double-click on the Layer2 icon on the left side of the dialog box.

  10. Select the LAYERS:Trial1(X), Pressure1(Y) data plot icon on the left side of the dialog box. This action opens the Line tab.

  11. Select Blue from the Color drop-down list, then click OK.

  12. Click OK to close the Layer 2 dialog box.

Note: If you see only the positive peaks in the layers_pressure1 data set, make certain that layer 2 is active and click the Rescale button [image] on the Graph toolbar.

Origin provides many methods to add layers to your graph. In addition to the Layer tool, you can select menu commands from the Edit menu. You can also right-click in the gray area outside the graph page (but inside the window) and add layers via the shortcut menu.


Arranging Layers in the Graph Window

In this section, you will add and arrange layers to set up a vertical 2 panel graph with left and right Y axes.

To add and arrange layers in the graph:

  1. Select Edit:Add & Arrange Layers.

  2. In the Total Number of Layers dialog box, type 2 in the Number of Rows text box.

  3. Click OK. Origin asks for permission to create 1 more layer.

  4. Click Yes.

  5. Click OK in the Spacing dialog box to accept the default settings.

To add the right Y controlling axis to the top layer:

  6. With the layer 3 icon selected, right-click in the gray area inside of the graph window (but outside of the page) and select New Layer (Axes):(Linked):Right Y from the shortcut menu.


Adding Data to the New Layers

To add the data to layers 3 and 4, you will use the Layer dialog box in the same way you added the data to layer 2.

To add data to the new layers:

  1. Double-click on the layer 3 icon. The Layer 3 dialog box opens.

  2. In the Layer 3 dialog box, select layers_potential2 from the Available Data list box, and click [image] to add the data set to the Layer Contents list box.

  3. Click OK.

  4. Double-click on the layer 4 icon.

  5. In the Layer 4 dialog box, select layers_pressure2 from the Available Data list box, and click [image] to add the data set to the Layer Contents list box.

  6. Click Layer Properties to open the Plot Details dialog box.

  7. Double-click on the Layer4 icon on the left side of the dialog box, then click on the LAYERS:Trial2(X), Pressure2(Y) data plot icon.

  8. Select Red from the Color drop-down list.

  9. Click OK to exit the Plot Details dialog box.

  10. Click OK in the Layer 4 dialog box.

  11. Click the Rescale button [image] on the Graph toolbar.


Linking Axes

You can link the axes of multi-layer graphs so that when you change the axis scale in the parent layer, the child layer's axis will change accordingly. Axes can be linked dimensionally, linked by axis scale values, or linked both dimensionally and by axis scale values.

To Link the X Axes:

  1. Double-click on the layer 3 icon to open the Layer 3 dialog box.

  2. Click Layer Properties.

  3. Select the Link Axes Scales tab.

  4. Select Layer 1 from the Link To drop-down list.

  5. In the X Axis Link group, select the Straight (1 to 1) radio button.

  6. Click OK to close the Plot Details dialog box.

  7. Click OK in the Layer 3 dialog box.

You can test the axis link by double-clicking on the bottom X axis (this is Layer 1) and changing the From or To values on the Scale tab. After clicking OK, the top X axis will reflect your changes.

Note: Though you only actively linked layer 3 to layer 1, all four layers of this graph are actually linked, directly or indirectly, to layer 1. Recall that when you added layer 2, you added a linked right Y axis. Recall also that when you added layer 4, you added a linked right Y axis. Thus, layer 2 is linked to layer 1, layer 4 is linked to layer 3, and layer 3 is linked to layer 1.

Note: Any change to the physical dimensions or scale values of linked layers should be done to the parent layer (this is layer 1 in the above example). Changing dimensions or scale values of a child layer will not effect changes in the parent layer, and the linking criteria will not be respected.


Customizing the Legend

Origin automatically displays a legend when you create a new graph. Furthermore, legends are layer-specific, so that if your graph has multiple layers, Origin displays a legend for each layer. If you add additional data to a layer, the legend will not update to include the new data unless you have selected the Auto Update check box on the Legends tab at the page level in the Plot Details dialog box (Format:Page).

You can update the legend for the active layer at any time by clicking the New Legend button [image] on the Graph toolbar. If there is currently no legend in the layer, Origin creates one.

A legend is really a specialized text label. Origin names the text label Legend to identify it. This name is stored in the legend's Label Control dialog box. You can open this dialog box by selecting the legend and then selecting Format:Label Control. If you should rename the legend, it retains it's current information, but it will no longer update when you click New Legend or when you add data to the layer.

A legend text label also uses special formatting to display the data set names and the data plot type icon (such as a line). If you double-click on the legend in the top layer of the current example, the in-place editing mode will display as shown in the following figure.

The %(1) is called substitution notation. This notation instructs Origin to display the data set name for the first data set in this layer.

When you are performing an in-place edit of any label, you can use substitution notation. For example, you can display the value of a specific data point in a data plot using the following substitution notation:

%(WorksheetName, ColumnNumber, RowNumber)

For example, if a worksheet is named Data1, and you have plotted columns A(X) and B(Y), you can display the value of the data point in column 2, row 3 using:

%(data1, 2, 3)

To enable use of this substitution notation, you must select the Link to Variables (%,$) check box in the Label Control dialog box (see the top of the dialog box, in the above figure).

In addition to substitution notation, Origin uses a special escape sequence to display the data plot icon in the legend. This special escape sequence is:

\L(DataListPosition)

Where DataListPosition is the data plot's position in the data list at the bottom of the Data menu.

If you double-click on a legend to enter the in-place editing mode, you will see the data plot icon, not the \L( ) escape sequence. This is because Origin does not support using escape sequences in the in-place editing mode. To use escape sequences, you must edit the label in the Text Control dialog box (see the following instructions).

To customize the legend:

  1. In the bottom layer, click on the text portion of the legend reading Potential1 (mV), then press DELETE.

  2. In the top layer, right-click on the text portion of the legend reading Potential2 (mV) and select Properties from the shortcut menu. This opens the Text Control dialog box.

  3. In the Text Control dialog box, type the following text, overwriting \L(1) %(1):

\L(1.1) Potential1

\L(2.1) Pressure1

\L(3.1) Potential2

\L(4.1) Pressure2

The preview box on the bottom of the dialog box shows what will display in the legend.

  4. Click OK.

  5. If necessary, drag the legend to a new location to minimize overlapping of graphic elements.

Note: The legend border may be somewhat larger than is needed. To resize the border/background without resizing the legend text, click once on the legend border to activate the “resize border only” handles. When a mouse-over produces a double-headed arrow, use your mouse to resize the legend border. The text point size will not be affected.

The legend now displays the data plot type representations from all the layers in the graph.

To prevent Origin from overwriting your custom legend (for example, if you should accidentally click the New Legend button on the Graph toolbar) you should rename the legend.

To rename the legend:

  1. Right-click on the legend text.

  2. Select Label Control from the shortcut menu that opens.

  3. Type Custom Legend in the Object Name text box.

  4. Click OK.


Saving the Graph as a Template

Template files retain information concerning how data should be displayed, but templates do not save any actual data. If you save the current graph window as a template, then the next time you need to create a similar graph, you can select your worksheet data and then select your custom graph template. Your custom template is recalled by clicking the Template button [image] on the 2D Graphs toolbar or by selecting Plot:Template Library.

To save your graph as a template:

  1. Right-click on the graph window title bar.

  2. Select Save Template As from the shortcut menu.

  3. Type Multilayer in the File Name text box.

  4. In the Template Category combo box, type My Templates.

  5. Click Save.

To test your template, you can make the Layers worksheet active, select all worksheet columns, then select Plot:Template Library. Select the My Templates category and then select your Multilayer template. Click Plot to plot your data.

This concludes the Multiple Layer Graphs tutorial.


Tutorial 8, Templates

Templates are Origin child windows that have been saved as files with visual properties set to pre-defined values. All Origin graphs are constructed by loading particular template files for each plot type.

Each of the three major child window types have an associated file extension for templates:

Child Window | Template File Extension
Worksheet | .OTW
Graph | .OTP
Matrix | .OTM

These files do not contain any data. However, in the case of graph templates (OTP files), you must have plotted data in order to save any plot styles you have defined.


All the elements shown (minus the data) are saved in the template file.

The Matrix Properties dialog controls the numeric display format as well as column width and internal data storage. (Changing internal data storage to anything other than double(8) may disable some analysis functions.)

The Matrix Dimensions dialog determines how much data is stored in the matrix (rows and columns) as well as the matrix mapping for plotting purposes. The columns of a matrix are linearly mapped to X values ranging from that assigned to the first column to that assigned to the last column. The rows of a matrix are linearly mapped to Y values ranging from that assigned to the first row to that assigned to the last row. These X,Y values are used for plotting the Z values contained in each cell.

The Set Matrix Values dialog lets you define an equation for setting Z values (the cell values) using either X and Y coordinates or i and j row and column numbers as parameters.

Creating Worksheet and Matrix Templates

Worksheets and Matrices are data containers that have similar visual editing dialogs which can be opened by double-clicking in the upper left of any worksheet or matrix window. Worksheet properties can also be accessed with the Format:Worksheet menu command. All the properties accessed from the Worksheet Display Control (or Matrix Display Control ) can be saved in a template.

  1. Open a new worksheet and double-click in the upper left corner (or select Format:Worksheet from the menu) to open the Worksheet Display Control dialog box. This dialog controls the size and appearance of many worksheet elements unrelated to data.

  2. Edit the properties to match these settings:

  3. Click the Page Color button to open the Page Color dialog. This dialog box has options for coloring the worksheet background.

  4. Edit the properties to match these settings:

  5. Click OK twice (to exit both dialogs).

  6. Double-click on the A(X) column in the worksheet to open the Worksheet Column Format dialog. This dialog box can be used to pre-set the plot type for select-and-click plotting and to control numeric formatting for display purposes.

  7. Edit the properties to match these settings:

  8. Click OK.

  9. Enter the numbers 1 through 8 in rows 1 through 8 of column A(X).

  10. Highlight cells in rows 1 through 8 of column B(Y), right click and select Set Column Values to open the Set Column Values dialog box.

  11. Enter col(A) in the large text box, select the AutoUpdate check-box, and click OK.

  12. The values in column B will be the same as in column A, but with different numeric formatting. Your worksheet should look like this:

  13. From the menu, select File:Save Template As and save your template file. If you overwrite the existing ORIGIN.OTW or ORIGIN.OTM, these templates will be used whenever you ask Origin for a new worksheet or matrix window.

The data you entered will not be saved as part of the template – only the worksheet appearance, data formatting and column formulas are saved. You should note that worksheets can have an associated Script that is also saved as part of the template.

As with worksheets, matrices use the Worksheet Display Control and Page Color dialog boxes for visual properties. Matrices also have three specialized dialogs available from the Matrix menu (visible only when a matrix is active). All of the properties set in these three dialog boxes are saved in the matrix template.

  • Set Properties

  • Set Dimensions

  • Set Values


Creating Graph Templates

Most Origin plot types are created by loading pre-saved graph templates and adding selected datasets. Most of the visual elements of a graph can be saved to a template and applied to new data. If you save a graph window plotted from a menu or a button using the existing template name, then all graphs created by that menu or button will have the new appearance. You can also save a graph template with your own name and it will become available in the Template Library (Plot:Template Library).

  1. Open a new worksheet and import the ASCII file GROUP.DAT from the TUTORIAL folder.

  2. Highlight columns B(Y) to D(Y) and select Plot:Line + Symbol from the menu.

  3. Select Format:Plot from the menu to open the Plot Details dialog.

Selecting any of the three branches in the tree at left (Graph, Layer or data plot -- designated as Group: A(X), B/C/D(Y) in this example) will activate individualized tabs on the right. Different data plot types have different tab sets. The Group tab that is shown is only available when multiple data plots have been grouped – which occurred automatically when we plotted multiple selected columns. This tutorial only touches on a small number of the many possible changes that you can make to a graph.

  4. Click on the Symbol tab and note the Automatic button next to Symbol Color (Symbol Color has inherited the Line color in this case).

  5. Click the Automatic button and select Individual Color => Red.

  6. In the Interior drop-down, select Open. This enables a new Fill Color button set to Automatic (Fill Color is coming from the Default Symbol Fill Color on the Graph page of the Options dialog available from the Tools menu).

  7. Click the Automatic button and select Individual Color => LT Yellow.

  8. Click the Group tab and note the additional properties available. We will keep the additional property increment boxes unchecked; they will not increment for each member of the plot group.

  9. Click the colors in the Details column of the Line Color row. This action enables a browse button [image] at the right of the color bar.

  10. Click the New button to open a dialog and right-click on any of the colors to open a shortcut menu. Note that you could edit or delete any color in the list or add new colors to the list.

  11. Select Load and choose Color List RGB. This changes the color list to just three colors.

  12. Right-click on Red and choose Delete. Click OK. Our color list now consists of only Green and Blue.

  13. Click the symbols graphic under Details in the Symbol Type row to enable its edit button. Click the edit button.

  14. Right click on any of the symbols and select Load and choose Symbol List Triangles.

  15. Right click and Delete the left-pointing and the right-pointing triangles and click OK. The incremental styles now consist of two colors and two shapes for a possible combination of four styles. If you clicked OK at this point, the first and third datasets (B and D) would have Green lines and Up triangles while the remaining dataset (and a fourth if present) would have Blue lines with Down Triangles. This would only use two style combinations. This is called Concerted behavior.

  16. Right-click anywhere in the Increment or Details column and select Nested.

  17. The property names are now gray boxes and we can reorder this list by dragging. Drag the Symbol Type property so it appears above the Line Color property and click OK. Our finished plot shows three of the four possible style combinations which would repeat for additional datasets added to the group. The graph should look like this:

  18. Select File:Save Template As… from the menu and name this template TEMPLATE TUTORIAL and click Save. Your template is now available for plotting any new data.

  19. Return to the original worksheet and add a new column. Enter 4, 8, 12, 16, 20 and 24 (to continue the progression of data).

  20. Highlight the B(Y) to E(Y) columns and select Plot:Template Library from the menu. Select My Templates in the Category list and then select TEMPLATE TUTORIAL (or whatever you named it) in the Template list.

  21. Click Plot to create a new plot based on your template. The graph should look like this:


Using Templates

There are three primary ways in which templates are called:

  • From the Template Library (graph templates).

  • From the File:New... menu (any template type).

  • From LabTalk or OriginC program code (any template type).

The graph template that we created in this tutorial relied on the datasets being members of a Group. Grouping occurs automatically when we select multiple columns for our plot.

Selecting new multiple datasets and plotting through the Template Library will show the new data correctly. You will also get this behavior if you select multiple columns and go to our graph template and select Graph:Add Plot to Layer. Plotting through the Template Library without selecting columns (which brings up the Select Columns for Plotting dialog box) or by loading a template through the File:New menu will not result in grouped data; all datasets will have the styles of the first dataset. If you subsequently group the datasets, then they will show the group plotting behavior we designed into the template.

Similarly, dragging multiple selected datasets onto a graph will exhibit group behavior while dragging individual datasets will exhibit individual behavior. You can always group the datasets after plotting by accessing the Layer dialog (double-click on the layer icon/number in the upper left of a graph window) and selecting those datasets that you wish to group.

Use of graph templates in LabTalk or OriginC similarly depend on the plotting methods used and whether that method groups datasets or not.

This concludes the Templates tutorial.


Tutorial 9, Themes

Themes provide a method for applying a suite of pre-defined format options to an object, a data plot, a graph window, or a set of graph windows, regardless of the target object/plot/graph window's original format or plot style. This differs from Templates which have the graph's (or the worksheet's and matrix's) appearance stored in a file which must be loaded by a user and which -- in the case of graph templates -- contain plot styles. With Themes, you can copy style elements (either in whole or in part) from one existing window and apply them to another. Only those elements defined in the Theme, are applied to the target graph.

Origin ships with a number of built-in Themes, plus you can edit any theme or create your own new Theme. You can also designate a System Theme which is applied to all graphs you make, overriding equivalent template properties. Group Incremental Lists – a subset of Themes – allow you to define a list for a particular property -- say color (e.g. red, purple, green, yellow) or fill pattern (e.g. dense diagonal left, sparse diagonal right, sparse cross-hatched) -- and have the list elements applied in either a Nested or Concerted incremental fashion to multiple grouped data plots.


Creating and Applying a Theme

You can create a new Theme by copying from an existing graph or Theme or by Adding a new Theme and building it one element at a time. A Theme will consist of any or all of the elements of a graph layer that you choose to include. Several dialogs assist you to this end.

The right-click context menu of a graph offers two options for creating a Theme from a Graph:

  • Copy Format holds the copied Theme in memory.

  • Save Format as Theme saves the copied Theme to a file.

Let’s begin by copying a Theme from an existing graph:

  1. Open the PLOTS.OPJ found in Origin’s TUTORIAL folder.

  2. Create a new worksheet and import (using ASCII) GROUP.DAT from Origin’s TUTORIAL folder.

  3. Highlight the B, C and D columns and click the Scatter (graph) button [image].

  4. Move the new Graph1 window off all existing windows and activate the MixedScale window so that MixedScale and Graph1 are both visible.

  5. Right click on the MixedScale graph (making sure you do not select anything with your click) and select Copy Format:All in the context menus.

When your click selects something – such as grid lines in the MixedScale window – you can only copy from or paste to that selection.

  6. Right click on the Graph1 window and select Paste Format.

Oops! Our data seems to have vanished from our graph!

By copying all formatting elements, we included scales that were not appropriate for the data in Graph1.

  7. Select Edit:Undo from the menu to restore our Graph1.

  8. Return to MixedScale and right click and select Copy Format:All Style Formats (which excludes Dimension and Scales).

  9. Return to Graph1, right click and select Paste Format.

Here is our graph now:

  10. Right click on our Graph1 again and select Save Format as Theme.

  11. Name the theme Before Edit, check the All Styles radio button and click OK.

The Theme is saved in the Themes folder in Origin and is now available for use.


The Theme Gallery and System Themes

  1. Select Format:Theme Gallery from the Origin menu (or press F7) to open the Theme Gallery dialog box.

Note the Theme that we saved (highlighted for clarity).

In this dialog box, you can select a theme to Duplicate, Delete or Edit. You can also Apply theme to Graph, Folder (all graphs in a folder) or Project (all graphs in a project). Selecting a check box under the System heading makes that item the System Theme (which applies to all graphs you create).

Clearing Exclude increment lists will show you Group Incremental Lists (which apply only to grouped datasets which have one element set to Incremental), as well as Themes. You can also construct a Theme from scratch using the Add button.

Let’s make a copy of our Theme, combine it with another available Theme and make the new Theme our System Theme:

  1. With our Before Edit theme selected, click the Duplicate button. (A new Theme is created and selected.)

  2. Click the Edit button to open the Theme Editor.

  3. Enter My system theme in the Description field.

  4. Click the List View box to collapse the "tree" into a simple list.

  5. Click the first Value item (the None next to Page.Background.BaseColor) and select Yellow from the color list.

  6. Scroll to the bottom of the list and click the color bar under Value next to Global.ColorList and click the button which appears on the right of the list.

  7. Right-click on any color in the dialog box that opens and select Load:Color Lists RGB.OTH (This is an example of a incremental list; it is a sort of limited theme which, in this case, only stores colors).

  8. Click OK twice (to close two dialog boxes) and return to the Theme Gallery.

  9. Double click on the Theme1 name and rename it After Edit.

  10. Check the box under System next to After Edit.

  11. Click Close.

Notice that After Edit appears on the status bar in Origin to indicate that a System Theme is in use.


Editing a Theme

  1. Return to our GROUP worksheet, select columns B, C and D and click the Column graph button [image]. Our new graph is clearly different than the Column plots we normally see in Origin.

  2. Double click on any column to open the Plot Details dialog box.

  3. Check the Increment boxes next to Border Color and Fill Color. This enables the short Red-Green-Blue color list in our Theme for group incrementing of our datasets.

  4. Click OK to close the dialog box.

Let’s make one more change using Themes. Press F7 to open the Theme Gallery.

  5. Select the Ticks All In theme and click the Apply Theme button.

  6. Close the Theme Gallery.

Our completed graph now has all tick marks pointing inward:

We made a change to our graph, so to save the change:

  7. Right click on the graph and select Save Format as Theme.

  8. Type After Edit in the Name of the New Theme text box, click All Styles and click OK.

A message box warns us that we are replacing an existing theme.

  9. Click OK.

  10. Return to our GROUP worksheet, highlight columns B, C and D and click the Line button [image] to create a line plot. Note that our System Theme can be applied to other plot types, too.


Tutorial 10, 3D Surface and Contour Graphs

There are two primary data structures in Origin: worksheets and matrices. Data stored in worksheets can be used to create any 2D graph and some 3D graphs, but in order to create a 3D surface graph or a 3D contour graph you must have your data stored in a matrix. Origin provides methods for converting worksheets to matrices, and for converting matrices to worksheets.


An Introduction to Origin Matrices

Matrices have numbered columns which are mapped to linearly spaced X values and numbered rows which are mapped to linearly spaced Y values. You can view the X and Y values in the matrix column and row headings by selecting View:Show X/Y. Each cell value in a matrix represents a Z value which is located in the XY plane by the cell's X value (determined by its column) and by the cell's Y value (determined by its row).

To learn more about the XY mapping in a matrix:

  1. Click the New Matrix button [image] on the Standard toolbar to create an empty matrix.

  2. Select Matrix:Set Dimensions to specify its dimensions and coordinates.

  3. In the Dimensions group, type 21 in the Columns text box and 21 in the Rows text box.

  4. In the Coordinates group, type -10 in both the First X (Columns) text box and the First Y (Rows) text box.

  5. In the Coordinates group, type 10 in both the Last X (Columns) text box and the Last Y (Rows) text box.

  6. Click OK. Use the horizontal and vertical scroll bars on the matrix window to verify that you have created a matrix with 21 columns and 21 rows.

  7. From the Origin menu, select View:Show X/Y.

  8. Use the horizontal and vertical scroll bars on the matrix window to verify that column (X) and row (Y) headings range from -10 to 10.

You can see that there are two ways to view the matrix column and row headings – by column or row number (View:Show Column/Row)or by the X and Y axis values (View:Show X/Y). When we create our 3D plot from this matrix window, you will see that both X and Y axis values range from -10 to 10, so it should be clear that the values that you specify in the Coordinates group of the Matrix Dimensions dialog will determine your 3D graph X and Y scale values.

  9. From the Origin menu, select Matrix:Set Values. This opens the Set Matrix Values dialog.

We can use this dialog to fill our empty matrix with Z values. You might, for instance, want to plot a mathematical function in 3D. To demonstrate:

  10. Type x in the Cell(i,j)= text box and click OK. Each cell in each column is filled with a number equal to the X value of that column.

  11. Re-select Matrix:Set Values and this time type y (replacing x) in the Cell(i,j)= text box. Click OK. Each cell in each row is filled with a number equal to the Y value of that row.

  12. Once more, select Matrix:Set Values and type the equation cos(x)+sin(y) in the Cell(i,j)= text box. Click OK. The matrix is filled with numbers.

The value in each cell, z, is determined by the relationship cos(x)+sin(y); where x=x coordinate value and y=y coordinate value. There is no particular significance to our made-up function; we only want to point out that when you specify x or y in a function in the Set Matrix Values dialog, the x and y coordinate values will be used to calculate the z value.

To create a 3D Contour plot from a matrix of values:

  13. Select Plot:Contour Plot:Contour-Color Fill to create a contour graph of the matrix data. Note the X and Y scales (-10 to 10) on the resulting graph.


Converting a Worksheet to a Matrix

In many, if not most, cases, your data will be stored not as a worksheet or spreadsheet of z values but rather as a worksheet of x,y,z triplets. When this is the case, you must convert your worksheet to a matrix of z value before you can create a 3D surface or contour plot. In this section you will learn how to convert an XYZ worksheet to a matrix so that it can be plotted as a 3D surface graph.

The data for this lesson is provided in an ASCII file.

To Import the ASCII File:

  1. Click New Project [image] on the Standard toolbar.

  2. Click Import ASCII [image] on the Standard toolbar.

  3. In the Origin \Tutorial folder, select Tutorial_5.DAT from the list of files.

  4. Click Open.

By default, when the file is imported, columns are added to the worksheet as Y columns. To convert the worksheet to a matrix it must be in an XYZ format. Recall that we can change a column’s plot designation in a couple of ways:

  • Double-click on a worksheet column heading to open the Worksheet Column Format dialog box.

  • Right-click on a column heading and choose Set As (X, Y, Z, etc.) from the shortcut menu.

To Change the Column Designation:

  1. Right-click on the C(Y) column heading.

  2. Select Set As:Z from the shortcut menu. Column C is now designated as a Z column.


Selecting the Type of Conversion

Origin provides several methods for converting worksheets to matrices, including direct, expand columns, 2D binning, regular XYZ and random XYZ conversions. The method that you choose will depend on the nature of your worksheet data.

We will give a brief run-down of the matrix conversion methods available to you, but we also encourage you to study the information in Worksheet to Matrix.OPJ in the \Samples\Analysis\Worksheet to Matrix folder in your Origin software directory.

  • Direct Conversion: A common format for XYZ data is to have X data values in the left-most column, Y data values in the first row, and Z values in columns 2 to N and rows 2 to M. If your worksheet (or Excel spreadsheet) data are organized in this way, you should probably use Direct Conversion.

  • Expand Columns: There may be cases where a screen editor which is used to create an ASCII file has an upper limit for the number of characters allowed on a single line. This upper limit may even be less than the number of columns required in the matrix. To compensate for this, one row of matrix data can be stored in multiple rows of an ASCII file. After this type of data is imported in a worksheet, the Expand Columns method will copy the number of worksheet rows that you specify into the first row of a matrix. Origin repeats this procedure to convert all rows in the worksheet.

  • 2D Binning: This method bins the XY data (creates a frequency count of data points falling within a given XY range) and stores the bin counts as Z values in a matrix.

  • Regular XYZ: In order for XYZ worksheet data to be considered Regular (a) each X value must have the same number of Y values and each Y value must have the same number of X values and (b) both the X and the Y data values must be equally

  • Sparse XYZ: This method converts “regular” XYZ data to a matrix by assuming missing values for missing X,Y data pairs.

  • Random XYZ: If your worksheet data are not of the previously mentioned types, then it can be classified as random data. The procedure for converting random XYZ data to a matrix is called gridding. Origin offers a number of gridding methods, including the method of Renka and Cline and a modification of Shepard's method. Both these methods are provided by the NAG® C Library eo1 Interpolation.

Most likely, you will use either the Regular XYZ or Random XYZ worksheet to matrix conversion methods. There is a simple test that you can use to determine which method is best suited to your data. This involves selecting only the X and Y columns of your XYZ worksheet and plotting the XY data as a scatter plot. If the resulting plot resembles an “orchard in plan view” (each scatter point is a “tree”), you can conclude that the data are Regular XYZ data. If the resulting plot displays no such regularity, it is Random XYZ data.

  1. Activate the Tutorial5 worksheet, select the X and Y columns of data, and click the Scatter Graph [image] button. The resulting plot looks like this:

Clearly, our data are not regularly spaced in the X and Y dimensions, so we will convert our worksheet to a matrix using one of Origin’s Random XYZ gridding methods.

To convert the worksheet to a matrix:

  1. In the Tutorial5 worksheet, select the C(Z) column heading.

  2. Select Edit:Convert to Matrix:Random XYZ. This opens the Random XYZ Gridding dialog box.

  3. Select Renka-Cline from the Select Gridding Method drop-down list if it is not already selected.

  4. Select the Show Plot check box if it is not already selected.

  5. Click Apply. A graph is created that shows the raw data as an XYZ scatter plot (the Show Plot check box) and the gridded data as a 3D Wire Frame plot.

The superimposition of the raw data on the gridded data allows you to quickly assess a gridding method’s effectiveness. Obviously, you don’t want your gridded data to depart radically from your raw data.

You can change the gridding method – each time clicking the Apply button – to compare the graph output for the various methods and then choose the method which produces a surface that most closely coincides with your raw data. For our example, the Renka-Cline method is the best choice.

  6. Click OK to close the dialog box.

  7. Activate the matrix window that contains the Renka-Cline gridding data.

Note: If origin cannot display an entire cell value, it displays # character in the cell. To increase the column width of the matrix, select Matrix:Set Properties, and adjust the Cell Width. This affects all columns in the matrix.


Graphing and Speed Mode

Now that you have your data in a matrix you can create any of Origin’s contour or 3D surface graphs. For this tutorial you will create a 3D color mapped surface graph.

To create a 3D color mapped surface graph:

  1. With the Renka-Cline gridding matrix active, select Plot:3D Color Map Surface. A Reminder Message reports that the graph will be displayed using Speed Mode.

Speed mode can be very useful for increasing the screen redraw speed of your graph by displaying a reduced number of data points. While the effect is not noticeable for plots created from smaller matrices, it can be very significant for plots of very large matrices.

At other times, you may find that reducing the number of plotted points is the only way to produce an intelligible data plot; imagine, for instance, trying to create a scatter plot of 1 million data points.

Speed mode reduces the number of plotted by points by systematically weeding out every nth data point from your dataset. Speed mode can be invoked at three levels depending on your requirements:

  • Video display

  • Clipboard Images and Graphic Export files

  • Printout

At the video display level, you can control speed mode by activating your graph and selecting Format:Layer from the menu. This opens the active layer's Plot Details dialog box. Select the Size/Speed tab and edit the Speed Mode, Skip Points if needed group.

This speed mode setting only effects the display of the graph in Origin. When you copy, export, or print your graph, all the data points will be included.

To invoke speed mode for Clipboard (copied) or exported images (BMP, TIF, JPG, etc.), select Format:Page. This opens the Plot Details dialog box. Select the Miscellaneous tab and, in the Performance group, select the If speed mode is enabled for display… check box. This will apply your speed mode settings to your copied/exported graph.

Lastly, you can reduce the number of data points in your printouts, using the settings in the Print Graph group of the Print dialog box (File:Print from the Origin menu).

  2. Click OK to close the speed mode reminder message. The matrix data is plotted as a color map surface graph. The different colors represent different Z-value ranges.

  3. From the Origin menu, select Format:Layer. This opens the Plot Details dialog.

  4. Select the Size/Speed tab.

  5. In the Speed Mode, Skip Points if needed group, clear the Matrix data, maximum points per dimension check box and click OK.

Note that the appearance of your graph has changed somewhat. The default speed mode settings limited the portion of the matrix that plotted to 15 rows and 15 columns, but by clearing this check box, we are now plotting the full20 rows by 20 columns of data.


Customizing the Graph

Origin gives you full control over the color mapping applied to the surface data plot. You can customize the color map by changing the settings on the Color Map tab of the Plot Details dialog box.

The Color Map tab displays the current color map; with different colors representing a particular range of z values from zMIN to zMAX. To edit an individual level or color, click on the value or color in the Level or Fill column. To edit the entire range of levels or colors, click on the Level or Fill column heading. To edit a range of levels, SHIFT + click on the desired values to select a range, then click on the Level or Fill column heading.

To change the number of levels in the color map:

  1. Right-click on your 3D Color Map Surface plot (take care not to click on the contour lines or on the side walls) and select Plot Details from the bottom of the shortcut menu.

Note: If you have a problem getting to Plot Details from the shortcut menu, you can choose Format:Plot from the Origin menu. Both will open the Plot Details dialog to the Color Map tab.

  2. Click on the Level column heading to open the Set Levels dialog box.

  3. Select the Num. of Levels radio button, type 12 in the associated text box, and click OK.

The Color Map tab updates to show twelve levels (plus levels for values above and below the maximum and minimum levels) and associated colors in the list box.


Customizing the Color Map

To customize the color fill characteristics:

  1. Click on the Fill column heading to open the Fill dialog box.

  2. From the From drop-down list, select Red

  3. From the To drop-down list, select Green.

  4. Click OK.

  5. In the Plot Details dialog box, click OK.

In addition to editing color ranges, you can edit individual colors. This is especially useful if you have an important section of your data that you want to highlight or make transparent.

To edit an individual color:

  1. Right-click on the color map surface plot.

  2. Select Plot Details from the shortcut menu.

  3. On the Color Map tab, click on the color associated with 1.75E -4.

This opens the Fill dialog. Note that this controls the fill color only for Level 1.75E-4.

  4. Select Dark Gray from the Fill Color drop-down list and click OK.

  5. In the Plot Details dialog box, Click OK.

The data plot redraws with the 1.75E-4 level in dark gray.


Adding Contours to the Color Map Surface Graph

To further enhance your graph, you can display contour lines or project your color map onto the top or bottom plane of your surface graph. This is done on the Surface / Projections tab of the Plot Details dialog box.

To project your color map onto the bottom plane of the 3D Color Map Surface graph:

  1. Right-click on the surface graph.

  2. From the shortcut menu, select Plot Details.

  3. Select the Surface / Projections tab.

  4. Under Bottom Contour, select the Fill Color check box

  5. Click OK.

With the current Z axis scale range and the current view angle, the surface plot substantially overlaps the bottom contour, blocking it from view. To make more of the contour visible, change the Z axis scale to begin from a lower value.

To Change the Z Axis Scale:

  6. Select Format:Axes:Z Axis to open the Z Axis dialog box.

  7. In the From text box, type -1E-4.

  8. Click OK.

The Z axis now displays a greater range below the surface graph. This decreases the amount of overlap of the surface plot and the projection, providing for a better visual presentation.


Changing the Perspective of the Graph

When you create a 3D graph, the 3D Rotation toolbar automatically opens. This toolbar provides buttons for controlling the perspective of the 3D graph. By rotating the graph you can further reduce the overlap of the surface plot with the contour, providing better perspective for viewing the graph.

To rotate the graph:

  1. On the 3D Rotation toolbar, click Tilt Up [image].

  2. On the 3D Rotation toolbar, click the Rotate Clockwise button [image].

This new perspective eliminates much of the overlap between the surface plot and the projection, and provides better visibility of the dark gray section of the surface plot.

This concludes the 3D Surface and Contour Graphs tutorial.


Tutorial 11, Nonlinear Curve Fitting

Origin offers several methods of fitting functions to your data. These methods vary in speed and complexity so that you may choose the method that best fits your needs.

In this tutorial, you will be introduced to fitting using the menu commands, the tools, the fitting wizard (NLSF Wizard), and the advanced fitting tool (NLSF). You will then use the NLSF to define your own function and fit sample data.


Fitting from the Menu

Origin offers access to several fitting functions directly from the Analysis menu. To perform a fit on your data using the menu commands, make sure that the data plot you want to perform the fit on is active, then select the type of fit you want to perform from the Analysis menu.

Most of the menu commands require no parameter input from you; the fit is performed automatically. Some may ask you for some parameter information, but will suggest default values based on your data.

After performing the fit, Origin displays the fit curve in the graph window, and types the results to the Results Log.

To perform a fit using one of the fitting functions available from the Analysis menu:

  1. On the Standard toolbar, click the Open button [image].

  2. In the \Tutorial folder, open the file FITEXMP1.OPJ. The project contains one worksheet and one graph.

  3. Verify that the graph is the active window. From the menu, choose Analysis:Fit Exponential Decay:First Order.

Origin generates a best-fit model for the dataset using the ExpDec1 fitting function. The best-fit curve is plotted as a red line through the data plot.

The Results Log reports data relevant to the fit: the date and time, the graph page, the curve fitting equation, chi-square and r-square values, and the parameter and parameter error values.


Fitting Using the Tools

For those who require a greater degree of control over your curve fit operations than the menu commands allow, Origin provides three fitting tools: the Linear Fit, Polynomial Fit, and Sigmoidal Fit tools. These tools can be opened from the Tools menu when either a worksheet or a graph is the active window.

To use the fitting tools, (1) select the data set or data plot you want to fit, (2) open the tool and customize the options on both tabs of the tool, and (3) click the Fit button on the Operation tab.

Begin this tutorial with a new project:

  1. Click New Project [image] on the Standard toolbar.

To perform a fit using the Sigmoidal Fit tool:

  1. On the Standard toolbar, Click the Import ASCII button [image].

  2. In the \Samples\Data folder, open a file named SigmoidalLog.DAT.

  3. In the SigmodalLog worksheet, select the B(Y) column and click the Scatter button [image], or, from the menu, choose Plot:Scatter. A scatter graph is created.

  4. Double-click precisely on the X axis (not on the axis tick labels). The X axis dialog box will open to the Scale tab (if you missed with your mouse-clicks and got another tab, just select the Scale tab).

  5. From the Type drop-down list, choose Log10 and click OK. The X scale changes to a log scale and the plot has taken on a sigmoidal shape.

  6. From the menu, select Tools:Sigmoidal Fit. The Sigmoidal Fit tool opens.

You will notice that Asymptotes and Parameters groups display some initial values. You can accept the defaults. In most cases, you will not need to adjust these, as Origin will initialize the parameters once you click the Fit button.

  7. Click the settings tab and notice that the Logged Data Fit Function group has two options for log scaled data: Boltzmann and Dose Response. We will leave the Dose Response function selected.

  8. Return to the Operation tab and click Fit. Origin performs a sigmoidal fit on the data and types the results to the Results Log

Note that the Logistic model was used. This model is commonly used for dose response studies in pharmacology. The formula for this, and other Origin fitting functions, can be found in the .FDF file (a text file) that resides in the \FitFunc folder. The formula for this particular function:

y = A2 + (A1-A2)/(1 + (x/x0)^p)

We should point out some of the post-fit functionality of the Sigmoidal Fit tool. At the bottom of the operation tab is a FindX/Find Y group that allows you to find a Y value from an inputted X value or an X value from an inputted Y value.

The methods differ for FindX and FindY, but the calculation of the X value from an inputted Y is very straightforward. The Y value is calculated using the best fit model that we just calculated using the Sigmoidal Fit tool. We merely input an X value and Origin calculates the Y value using the above equation and parameter values.

To find a Y value based on an inputted X value:

  1. Enter 40 in the FindX text box.

  2. Click FindY. Origin calculates a Y value of 40.22945.

You could get out your calculator and see for yourself that our best fit model will return a value of 40.22945 when X=40, but rather than do that, let’s digress here for a moment and have a bit of fun.

  3. On the Standard toolbar, click the Script Window button [image]. This opens the Script window.

Origin’s Script window has many uses, but one of the simplest applications is to use it to perform calculations. We demonstrate this in one of the later Command Line Tutorials, but let’s get our toes wet now and learn a bit more about one of Origin’s many capabilities.

  4. In the Script window, type:

A1=

  5. Press ENTER.

Origin responds with 96.56111. Note that this is the value Origin calculated for the parameter A1. Origin has temporarily stored our parameter values in memory.

  6. Now let’s type our Logistic equation into the Script window:

y = A2 + (A1-A2)/(1 + (x/x0)^p)

  7. Press ENTER.

Origin responds by placing a semicolon at the end of the equation.

Now, let’s give Origin our X value of 40 and see it return our Y value.

  8. Type in the following into the Script window:

x=40;

  9. Press ENTER.

Origin responds by placing a semicolon at the end of the line.

  10. Now type in:

y=

  11. Press ENTER.

Origin places a semicolon at the end of the line and returns:

Y=40.22945

This is, of course, our FindY value.

The point of this little digression was simply to demonstrate that Origin is a very powerful program. We hope that as you begin to work with Origin, that you will come to appreciate the fact that it is much more than a top-notch scientific graphics package. It is also a very powerful analysis package that provides a wide variety of tools for “massaging” and analyzing your data.

Now, let’s return to our Curve Fitting tutorial.


Fitting Comparison

A Fit Comparison tool is available to determine if two data sets are representative samples drawn from the same population. This tool compares the data sets by fitting the same function to the data. It then uses an F-test to determine whether the data sets are significantly different from each other. To open the Fit Comparison tool when a worksheet or graph is active, select Tools:Fit Comparison.

To compare two datasets using the Fit Comparison tool:

  1. Open a new worksheet by clicking on the New Worksheet button [image].

  2. Click the Import ASCII button [image].

  3. In the \Samples\Data folder, open a file named Lorentzian.DAT.

  4. Select columns B(Y) and C(Y).

  5. From the menu, select Tools:Fit Comparison…

  6. Verify that the Datasets group registers Lorentizian_B and Lorentzian_C.

  7. Category should be set to Origin Basic Functions.

  8. From the Function drop-down list, select Lorentz.

  9. Click Compare.

Origin performs a comparison of the selected datasets and types the result to the Results Log. In this particular case, Origin finds that, at the 0.05 level, the two datasets are statistically different; it is highly unlikely that they represent samples drawn from the same population.

Note: The Refresh button should be used to update the Datasets or Category and Function drop-down lists when, for instance, different datasets are selected for comparison , new datasets are added to the project file, or new functions are defined in the Nonlinear Least Squares Fitter (NLSF).


The Fitting Wizard

Origin provides two, progressively more advanced tools for performing nonlinear least squares fitting: the NLSF Wizard and the Advanced Fitting Tool (the NLSF, or Nonlinear Least Squares Fitter).

The wizard – as it’s name implies – is quite easy to use but it doesn’t allow as much control over the fitting process as the NLSF does. For instance, you cannot define a new fitting function using the Wizard; this must be done through the NLSF (though once defined via the NLSF, user-defined functions become available in the Wizard). In addition, to fit multiple data sets to a function, fit with multiple independent or dependent variables, or run scripts at specified triggers (for example, after a fit is performed), you must use the NLSF.

Yet, the Wizard provides enough control to be an effective and flexible fitting tool. It is highly customizable, allowing you to do such things as hide unneeded pages and save your procedure to a button for repeat analyses using other datasets.

To open the NLSF Wizard when a worksheet or graph is active, select Analysis:Nonlinear Curve Fit:Fitting Wizard.


The Advanced Fitting Tool

The advanced fitting tool (NLSF) is Origin's most powerful and complex method of fitting data. To open the NLSF when a worksheet or graph is active, select Analysis:Nonlinear Curve Fit:Advanced Fitting Tool.

There are two display modes available for the NLSF: basic and advanced. You can switch between modes by clicking the More button in the basic mode or the Basic Mode button in the advanced mode.


The Basic Mode

The basic mode of the NLSF provides an abbreviated fitting function list and a less complex interface than the advanced mode. Additionally, the basic mode offers less control over the fit and less customization of the reported results.


The Advanced Mode

The advanced mode lets you customize all aspects of the fitting process. It provides access to many more fitting functions than the basic mode and the functions are separated into categories to facilitate searching. The advanced mode also has its own menu and toolbar to provide access to all its features.

To select a function in the advanced mode, first select Function:Select from the NLSF menu if the Select Function page is not active. Then select the appropriate category from the Categories list box, and select the desired function from the Functions list box. Once a function is selected, the procedure for fitting is the same as for fitting after you define your own function (see the following sections).


Defining a New Fitting Function

In this tutorial, we will define and compile a new fitting function using Origin C, Origin’s built-in programming language. We could also define the fitting function using LabTalk script, Origin’s built-in scripting language. However, defining the function using Origin C delivers more in terms of flexibility and speed (up to 20X faster than LabTalk).

To Open the Project File:

  1. On the Standard toolbar, click the Open button [image].

  2. In the \Tutorial folder, open ASYMGAUSS.OPJ. The project opens showing a worksheet containing data and a graph window containing a data plot.

We will define a new function for fitting data with an asymmetric Gaussian peak shape. An asymmetric Gaussian is a peak function characterized by different widths on either side of the peak center, and is defined as:

The basic mode of the NLSF only permits defining new functions with LabTalk script. We will use the NLSF’s advanced mode so that we can use Origin C.

To define your own Function in Advanced Mode:

  3. From the menu, choose Analysis:Nonlinear Curve Fit:Advanced Fitting Tool. This opens the NLSF.

  4. If the NLSF opens in the basic mode, click More to switch to Advanced mode.

  5. From the NLSF menu bar, select Category:New. This opens the Category Name dialog box.

  6. Type in:

Tutorial Example

  7. Click OK.

Tutorial Example is added to the Categories list.

  8. From the NLSF menu bar, select Function:New. This opens the Define New Function dialog box.

  9. In the Name text box, type the following:

AsymmetricGaussian

Note: Spaces are permissible in category names but not in function names.

  10. Select the User Defined Param. Names check box.

  11. In the Parameter Names text box, enter:

y0,A, xc, sig1, sig2

  12. Verify that the Use Origin C check box is checked, and click the Edit in Code Builder button. The Code Builder IDE opens with a specialized window intended for defining new fitting functions.

  13. In the editable part of the Code Builder workspace, type in the following lines of code:

double B = A / (0.5 * (sig1 + sig2) * sqrt(2 * pi));

if( x < xc )

y = y0 + B * exp(-0.5 * ((x - xc) / sig1) ^ 2);

else

y = y0 + B * exp(-0.5 * ((x - xc) / sig2) ^ 2);

  14. Click the Compile button to compile the function code. Origin types Done! to the Code Builder output window.

  15. Click the Return to NLSF button. This returns you to the NLSF tool. Note that our new fitting function registers in the Definition text box.

  16. Click Save to save the function.

The function is saved under the name AsymmetricGaussian. This function will now be available in the list of functions under the Tutorial Example category. To verify this: From the NLSF menu, select Function:Select. To return to the current view, select Function:Edit.


Assigning the Function Variables to the Data Sets

The next step is to assign the independent and dependent variables to the corresponding X and Y data sets.

To assign the function variables to the data sets:

  1. From the NLSF menu, select Action:Dataset. This opens the Select Dataset dialog box.

  2. Select the y variable in the top list box.

  3. In the Available Datasets list box, select data1_b.

  4. Click the Assign button to the right of this list box. Note that the x and y data sets are assigned to the dependent and independent variables (top list box).

How did Origin know to assign the data set data1_a to the independent variable x? Origin assumes that the y data set should be associated with the nearest x data set to the left of the y data set. While Origin can work with other arrangements, this is the default Origin behavior.


Assigning Initial Parameter Values

For the iterative fitting process to succeed, the NLSF must have reasonably good initial parameter estimates. You can manually assign initial values or you can write code that analyzes your data and performs some parameter initialization. You can also simulate the fit curve by trying various parameter values; when the simulated curve and raw data plot converge, you can assume that you have arrived at reasonable initial parameter values.

Note: Origin provides data set-specific parameter initialization for all built-in fitting functions.

In this tutorial, we will manually assign the initial values during the fitting session. For more information on simulating the fit curve, search on “simulate” in the Origin help file (Help:Origin). For further information on writing your own parameter initialization code, search on “parameter initialization.”


Fitting the Data

We are now ready to fit our data using our AsymmetricGaussian function.

To fit the data:

  1. From the NLSF menu, select Action:Fit. This activates the Fitting Session dialog box.

  2. Type in the following initial parameter values:

y0: 10

A: 10

xc: 5

sig1: 1

sig2: 1

  3. Click the Chi-Sqr button. The reduced chi-squared value for the current parameter values displays in the view box.

  4. Click the 100 Iter. button.

Origin fits the data, performing a maximum of 100 Levenberg-Marquardt iterations. The fit curve displays in the graph. The reduced chi-squared value and the number of iterations performed are reported in the NLSF view box. The updated parameter values are shown in the Value text boxes.

Note: You can also define your initial parameter values in the Parameter Initializations dialog box (from the NLSF menu, Scripts:Parameter Initialization), and they will be saved with the .FDF file.


Post Fit Output Options

After fitting your data, you can opt to create a worksheet that contains the results of your fitting session. Additionally, you can have your curve fit parameters written to the results log or in a label pasted to the graph window.

To create a worksheet with the fitting results:

  1. From the NLSF menu, select Action:Results.

  2. In the Other Options group, click the Param. Worksheet button. Origin creates worksheet named Parameters1. The worksheet contains the curve fit results including parameter values, confidence limits, r-square value, etc.

To write parameter values to the results log and paste them to the graph window:

  3. From the NLSF menu, select Scripts:After Fit.

  4. Make sure that the Write Parameters to Results Log and Paste Parameters to Plot check boxes are selected.

  5. Click the Close button [image] in the upper right hand corner of the NLSF.

The parameter values are pasted to the graph of the raw data and the best-fit curve. Parameter values are also written to the Results Log.

This concludes the Nonlinear Curve Fitting tutorial.


Tutorial 12, Creating Presentations with the Layout Page

Origin’s Layout window provides a “canvas” for displaying and arranging pictures of worksheets and graphs from other windows in your project, as well as text and other annotations. The Layout window is the only means for presenting worksheet data along with your graph.


Introduction

This tutorial will show you how to add and arrange various elements on a layout page, how to edit elements of the layout page and how to export the layout page to one of Origin’s many graphic export file types.


Adding Graphs, Worksheets and Text to the Layout Page

Pictures of graphs and worksheets are added to the layout page by clicking the buttons on the Layout toolbar, or by selecting associated menu commands. Text can be added with the Text tool, or by pasting from the Clipboard. Shapes, lines, and arrows can be added using the drawing tools from the Tools toolbar.

The data for this tutorial lesson is provided in an Origin project file.

To open the project file:

  1. Click the Open button [image] on the Standard toolbar.

  2. In the Origin \Samples\Graphing\Statistical Graphs subfolder, select Histogram.OPJ from the list of files.

  3. Click Open.

The Origin project file opens. You should see a notes window and a histogram in a graph window. The project file contains other windows in another folder. Recall that the Project Explorer workspace is toggled on and off by pressing ALT+1.


Creating a New Layout Page

To create a newLayout page:

  1. Click the New Layout button [image] on the Standard toolbar. A blank layout page opens.

  2. If the layout page is displayed in landscape orientation, right-click on the gray area just outside of the layout page (but inside the layout window), and select Rotate Page from the shortcut menu. The layout page will now display in portrait orientation.


Adding Pictures and Text to a Layout Page

You can add pictures of any worksheet or graph from your current project to a layout page. Remember as you work with these that they are only pictures. Graphs and worksheets in the layout window are not directly editable. If you want to change some details of the picture subsequent to adding it to your layout window (a line color or worksheet cell value, for example), you must make the change in the source window. After making your changes, activate the layout window and click the Refresh button [image]. This will update the pictures in the layout window.

To add pictures of graphs and worksheets to the layout page:

  1. Right-click in the layout page (do not click in the gray area just outside the page) and select Add Graph from the shortcut menu.

  2. Select HistGraph from list box in the Select Graph Object dialog box and click OK.

  3. Drag out a box on the bottom half of the layout page. After you release the mouse button, a picture of the HistGraph graph displays in the layout page.

When the graph picture is selected, you can drag the picture to a new location or use the sizing handles to resize it.

  4. Right-click on a blank section of the layout page and select Add Worksheet from the shortcut menu.

  5. Select Bin1 from the list box in the Select Worksheet Object dialog box and click OK.

  6. Drag out a box in the top half of the layout page, leaving some space at the top for a title.

After you add the worksheet picture to the layout page, it may display a blank area to the right of the last worksheet column, and it may include a number of blank worksheet rows.

To remove blank areas from the worksheet picture:

  1. Right-click on the worksheet picture in the layout page and select Keep Aspect Ratio from the shortcut menu. This cancels the selection.

  2. Drag one of the control handles on the right edge of the worksheet picture so that only the four worksheet columns display.

  3. Drag one of the control handles on the bottom edge of the worksheet picture so that only the worksheet rows with values display.

  4. Re-position the worksheet picture in the layout page.

  5. Click outside the worksheet picture (but within the layout page) to cancel the selection.

To add text to the layout page using the text tool:

  1. On the Tools toolbar, click the Text Tool button [image].

  2. Click above the worksheet picture in the layout page.

  3. Before you start typing, from the Format toolbar, select 36 from the Font Size combo box.

  4. Type Histogram Data in your new text label.

  5. Click outside the label to cancel text editing mode.


Customizing the Appearance of the Layout Page

In this section, you will fine tune the position of the pictures displayed in the layout page. In addition, you will make changes to the source graph window to change the picture's appearance in the layout page.

There are several ways to arrange pictures on the layout page. You can drag the pictures and “eyeball” the position, use the Object Edit toolbar to align and group objects, or you can view the layout page grid (View:Show Grid) and align the pictures using the grid lines as a guide.

To arrange the pictures on the Layout page using the Object Edit tools:

  1. If the Object Edit toolbar is not currently open, select View:Toolbars. From the Toolbars tab, select the Object Edit check box, then click Close.

  2. Click on the Histogram Data text label to select it.

  3. Press SHIFT and click on the worksheet picture, and then on the graph picture (in that order). All three objects are now selected in the layout page.

  4. Click the Vertical button [image] on the Object Edit Toolbar. The pictures align vertically on the last selected picture (the graph).

  5. Click in the layout page but outside of the pictures to clear the selection.


Editing the Pictures in the Layout Page

As mentioned, you do not edit the worksheet and graph pictures directly in the layout page. Instead, you edit the source window and update the pictures in the layout window. Origin provides a shortcut menu command to take you from a worksheet or graph picture to the source window.

To edit a source window from the Layout page:

  1. Right-click on the histogram picture in the layout page.

  2. From the shortcut menu, select Go To Window. Origin activates the HistGraph window.

  3. Right-click on the histogram and select Plot Details from the shortcut menu. The Plot Details dialog box opens.

  4. Select the Data tab.

  5. Clear the Automatic Binning check box.

  6. In the Bin Size combo box , type 5. Click OK.

  7. Double-click on the Y axis in the HistGraph window. This opens the Y Axis dialog box.

  8. Select the Scale tab (if not already selected).

  9. In the To text box Type 600; in the Increment text box type 100. Click OK.

  10. Activate the layout page window.

  11. Click the Refresh button [image] on the Standard toolbar.


Exporting the Layout Page

Once you have tweaked your layout page presentation, you might wish to print it out for a poster presentation or you might export the layout page to another application.

You can export your graph or layout page by copying and pasting or you may opt to use any one of a number of built-in raster and vector graphic export filters to create a separate image file.

Before you export your layout window we should say something about the settings that control the size of the exported image.

  • For Clipboard (copied) and vector file types, image dimensions are controlled by (1) page size (default printer page size) and (2) the settings in the Copy/Export Page Settings group on the Page tab of the Options dialog box (from the menu, select Tools:Options).

Note: Common vector file types are EPS, PDF, WMF, EMF, AI, CGM, and DXF. Vector files are often preferred by print publications because they can be resized without loss of image quality. These formats generally create moderate file sizes.

  • For raster file types, image dimensions are a function of (1) page size and (2) export file resolution (commonly between 72 and 600 dpi). In effect, raster files are dimensionless because when you multiply page size by dpi, you get only "dots"; the dimensions cancel out. Thus, the dimensions of a raster file are controlled by the resolution of the rendering device, be it a 96 dpi video display or a 1200 dpi printer.

Note: Common raster formats are BMP, TIF, JPG, GIF, PNG and TGA. Taster formats are good for reproducing graphs with considerable detail and color variation. They are not highly scalable, rescaling often leads to loss of detail and color. These formats can produce a very large file size when high resolutions and colors are needed.

Since we are going to be exporting a vector file shortly, let’s open the Options dialog box and have a look at the settings on the Page tab.

  1. From the menu, select Tools:Options.

  2. In the Options dialog box, select the Page tab.

As mentioned, the settings in the Copy/Export group control the dimensions of Clipboard and vector images. The default settings are pictured here. In most cases, you will only need to concern yourself with the Ratio, Margin Control, and Clip Border Width settings. Briefly:

  • The Ratio combo box specifies the dimensions of your exported image as a percentage of your graph page size. You can choose a number from the associated drop-down list or you can type directly in the text box. A ratio of 100 will create an export image that has the same dimensions as your graph page; a ratio of 50 will produce and image that is half of your page size, etc.

  • The Margin Control list allows you to specify how much of a margin (surrounding white space) to include with your graph or layout page pictures. The choices are Border, Tight and Page. If you choose Border, Origin will use the Clip Border Width setting to determine margin width (see the next item for an explanation). If you choose Tight, Origin will draw the smallest rectangle that it can around your all objects in your graph or layout page and export only what is inside that rectangle. This usually minimizes white space. If you choose Page, Origin will export the entire page – that is, whatever is within the white background area of your page or layout window. This maximizes white space

  • The Clip Border Width combo box, in concert with the Margin Control = Border, specifies how much of a margin to include with graph or layout page objects, as a percentage of page size.

Attention to Ratio and Margin Control/Border width settings will suffice for most situations. You are advised to leave the Advanced radio button selected and Set Resolution at 300 (or perhaps 600). However, you are encouraged to experiment with these settings, as you have time, so that you will better understand how they affect the exported image.

You should know that image export can be a fairly complex topic and there is much more to say about it than we can say here. For more information, select Help:Origin and search on exporting your graph or layout page.

Returning to our tutorial, we will export our histogram layout page as an EPS file. Encapsulated PostScript files are highly scalable; that is, they can be resized without loss of detail. For this reason, they are a sensible choice for print publishing.

To export the layout page as an Encapsulated PostScript file:

  1. Make certain that your histogram layout page is the active window. From the menu, select File:Export Page. The Save As dialog box opens.

  2. In the File Name text box, type Presentation1.

  3. In the Save as type: list, select Encapsulated PostScript (*.EPS).

Each export file type has its own set of Export Options (pertaining to resolution, color density, etc.). If you want to view or modify those export options, you must select the Show Export Options dialog box at the bottom of the Save As dialog box.

  4. Select the Show Export Options check box.

  5. Specify a Save in folder (the Origin software folder is fine) and click Save.

This opens a message reminding you that the Copy/Export page settings will be used to determine the size and the margins of your EPS image.

  6. Click OK to close the reminder message. The EPS Options dialog box opens.

In most cases, these default settings will work well, but you may find that changing one or more of them is sometimes necessary (in doing this, you will create new default settings).

Note: When you have determined that your export options are working satisfactorily, you may clear the Show Export Options check box in the Save As dialog box, and bypass the export options dialog. Export options are stored for each export file type.

One thing that can be handy when working with EPS files, is to create a TIFF (.TIF) preview. Some applications do not display EPS files and will instead display a picture placeholder. If you opt for a TIFF preview, the receiving application can use the appended TIF file to display your image.

  7. In the Preview group, select the TIFF radio button if it is not currently selected.

  8. Click OK.

The layout page is exported as an EPS file and can be inserted into any application that recognizes this file type. If you have Adobe Photoshop or Ghostview, you should open your newly created EPS file and have a look.

This concludes the tutorial on Creating Presentations with the Layout Page.


Programming Tutorials

Origin is designed to meet the graphing and data analysis needs of scientists and engineers in diverse areas of academics and industry. To accomplish this, Origin provides a broad range of tools for importing, analyzing, graphing, presenting, and exporting data. As you gain familiarity with Origin, you may want to customize Origin to meet your specific graphing and analysis needs. Common customization needs include:

  • Adding functionality to Origin by creating new importing, analysis, graphing, and exporting routines.

  • Automating the work that you do in Origin.

  • Performing numerical computation and simulations in Origin.

These types of customizations can be achieved using Origin's programming language, Origin C and/or Origin’s scripting language, LabTalk.

These tutorials are designed to give you a broad overview of the basics of programming in Origin:

Tutorial 13, The Origin Script Window

Tutorial 14, Introduction to Origin C and Code Builder

Tutorial 15, Adding New Functions to Origin

Tutorial 16, Debugging Origin C Files using Code Builder

Tutorial 17, The Code Builder Workspace

Tutorial 18, Organizing and Accessing Origin C Functions

Tutorial 19, Calling NAG Functions From Origin C

Tutorial 20, Accessing Internal Origin Objects

Tutorial 21, Automation Example

Tutorial 22, Programming Cues to Enhance User-Friendliness

Tutorial 23, Advanced Scripting using LabTalk


Tutorial 13, The Origin Script Window

The Script Window provides a convenient way to send LabTalk script commands to Origin. Script commands can range from simple math and data operations, to calling Origin C functions, and executing a collection of commands from a script file. In this tutorial you will use the Script Window to do simple calculations, and to read and write to Origin worksheets.


Performing Calculations

One of the more basic uses for the Script Window is as an interface to perform simple calculations.

  1. From the Origin program menu, choose Window:Script Window. The Script window opens.

  2. Type the following in the Script window:

2+2=

  3. Press ENTER. Origin appends a semi-colon the end of the line and returns:

2+2=4

  4. Type the following:

log(100)=

  5. Press ENTER. Origin appends a semi-colon at the end of the line and returns:

LOG(100)=2

Each statement in a LabTalk script must end in a semi-colon. However, if your intent is to execute a single line of code from the Script window, you do not type the semi-colon at the end of the line . Simply press ENTER to complete the line. Origin will append a semi-colon for you and execute the Script command.

If you are typing multiple lines of code in the Script window and you do not want code to execute each time you enter a carriage return, then you should type the semi-colon at line’s end and press CTRL + ENTER. To execute multiple lines of script from the Script window, verify that the Script window’s Edit:Script Execution menu command is checked, select the entire script and press ENTER.

You can re-execute a previously-typed command by either placing the cursor anywhere on the line and pressing ENTER, or by removing the semi-colon at the end of the line and pressing ENTER.

Note: Any mathematical function – built-in as well as user-created – can be executed from the Script Window.


Reading and Writing Worksheet Values

You can also use the Script Window to read and write worksheet values, or to perform math operations on datasets.

  1. Enter the following data into a fresh worksheet:

  2. To return the value in the first cell of the second column, type the following:

cell(1,2)=

  3. Press ENTER. Origin returns:

CELL(1,2)=6

You can also use the column name and row number to reference cell values.

  4. Type the following:

col(B)[1]=

  5. Press ENTER. Origin returns:

COL(B)[1]=6

Note: In addition to using the column name, you can also use the dataset name. In LabTalk, the syntax for naming datasets is worksheetName_columnName. So, For example, Data1_A[1]= would return the first element of column A in worksheet Data1. Also, if the worksheet that you are referencing is the active window, you can use the LabTalk string variable %H, in place of the worksheet name. For example, %H_A[1].

To subtract the value in row 1 of column A, from all the values in column B…

  6. Type the following:

col(B)=col(B)-col(A)[1]

  7. Press ENTER. Your worksheet now reads:

Let’s use what we have learned about executing multiple lines of script in the Script window. We will multiply every value in a column of data by some constant b.

  8. Type the following:

b=3;

Press CTRL+ENTER. Recall that this gives us a carriage return without executing the command.

  9. Now type:

col(A)=col(A)*b;

Again, Press CTRL+ENTER.

  10. Choose Edit from the Script window’s menu bar. Script Execution should have a check mark next to it; if not, single-click on the menu item to place a check mark there.

  11. Now, select the two lines of script that you just entered into the Script window and press ENTER.

Your worksheet now reads:

Note: The following C notation is also supported:
b=3;
col(A)*=b;

You can also use linear interpolation or extrapolation on a specified X dataset to find the corresponding interpolated or extrapolated value in a Y dataset. This requires using a new notation with parentheses ( ) instead of brackets [ ].

In this example, data1_b is a Y dataset and (4) is a value in an X dataset (data1_a) for which you want to find a corresponding, interpolated Y value.

  12. Type the following:

data1_b(4) =

  13. Press ENTER. Origin returns:

DATA1_B(4)=5.333333

This is a line plot of our simple worksheet data. You can see that our interpolated Y value – the one corresponding to X = 4 – is 5.333333.

This concludes the Origin Script Window tutorial.


Tutorial 14, Introduction to Origin C and Code Builder

Origin C supports a nearly-complete ANSI C language syntax as well as a subset of C++ features including internal and DLL-extended classes. In addition, Origin C is “Origin aware.” This means that Origin objects such as worksheets and graphs are mapped to classes in Origin C, allowing direct manipulation of these objects and their properties from Origin C.

Origin C’s integrated development environment (IDE) is called Code Builder. Code Builder provides standard tools for writing, compiling, and debugging your Origin C programs. Once an Origin C function is compiled, the function can be called in various ways from the Origin or Code Builder workspaces.

This tutorial introduces you to Origin C and Code Builder by showing you how to write, compile and call a function that types the message “Hello World!!!”.


Hello World!!!

  1. On the Origin Standard toolbar, click the Code Builder button [image].

  2. On the Code Builder toolbar, click the New button [image].

In the New File dialog, select C File.

In the File Name text box, type Tutorial.

In the Location text box, select the \Origin C subfolder ( Note: The Browse button looks like this: ).

Click OK. A file named Tutorial.c opens in the Code Builder workspace.

  3. Type the following beneath the line that reads // start your functions here:

void test ()

{

printf(“Hello World!!!\n”);

}

  4. On the Code Builder workspace Standard toolbar, click the Build button [image]. This compiles the test function.

  5. To call this function, click in the upper pane of the LabTalk Console. This is located in the lower right corner of the Code Builder workspace (This is the default location. If the LabTalk console isn’t visible, select View:LabTalk Console from the Code Builder menu and make sure that the menu item is checked).

  6. Type the following LabTalk function call in the LabTalk Console:

test

  7. Press ENTER.

To test this function in the Origin Script Window:

  8. Return to the Origin workspace, and select Window:Script Window.

  9. In the Script window, type the following:

test

  10. Press ENTER.

"Hello World!!!" displays in the Script Window.

This concludes the Introduction to Origin C tutorial.


Tutorial 15, Adding New Functions to Origin

Functions written in Origin C are accessible from the Origin interface, such as the script window, provided they meet some criteria. The function should return either void (as in the previous tutorial), double, string, or vectors of type double or string. Variables passed to the function from Origin should be of type double, or string, or vectors of these types. Functions that do not meet this criteria are not callable from the Origin interface, but can be called from within other Origin C functions. Note that although an Origin C function that accepts and returns type int can be called from the Origin interface, since the interface only supports double this may result in truncation of data.

In this tutorial, you will be introduced to writing a math function that returns computed values. We will first create a function that returns double to Origin, and then create a function that returns a vector of doubles.


Adding a New Function

  1. Start a new Origin C file in Code Builder.

  2. Enter the following code:

double myfunc1(double x, double a)

{

return sin( a * x );

}

  3. Click the Build button [image] to compile the function.

This function can now be called from the Origin interface, from places such as the script window.

  4. Go to the script window, and type the following lines, pressing ENTER at the end of each line:

y = myfunc1(2, 3)

y=

You can also use worksheet cells instead of absolute numbers:

  5. Make a worksheet active, fill in a number in the first row of column A. Then type the following in the script window and press ENTER:

col(B)[1] = myfunc1(col(A)[1], 3)

Note that a function such as myfunc1, that accepts and returns double, can also be used to perform vector operations.

  6. Fill rows 1 thru 10 of Column A with some numbers, and type the following in the script window:

col(B) = myfunc1(col(A), 3)

In the above example, Origin calls the myfunc1 function for each row of column A. For performing vector operations such as above, it is more efficient to write functions that accept and return vectors.

  7. Go back to in Code Builder and add the following function to the same file, and compile the file by clicking on the Build button [image].

vector<double> myfunc2(vector<double>& vecIn, double a)

{

vector<double> vecOut;

vecOut = sin( a * vecIn );

return vecOut;

}

  8. Go back to the Origin interface, fill Column A with some new numbers, and type the following in the script window:

col(B) = myfunc2(col(A), 3)

The function myfunc2 is called only once for computing the entire column.

Note that you can use such functions in other places such as the “Set Column Values” dialog. The Auto Update feature of “Set Column Values” can be set by checking the appropriate checkbox in that dialog. As long as the Origin C function is compiled and ready to be called from Origin, any changes in the source column will result in an update of the destination column.

This concludes the Adding New Functions tutorial.


Tutorial 16, Debugging Origin C Files using Code Builder

Errors in source code may be thought of as falling into three broad categories: syntactic, logical, and run-time.

When you compile or “build” an Origin C source file, the compiler checks the file for syntactic errors. If the source file successfully compiles (i.e. it compiles without generating error messages ), the functions in the file are rendered ready to be executed. Thus, removal of syntactic errors, while sometimes tedious, is a fairly straightforward process.

Locating logical and run time errors in your source code can be more problematic. Debugging is the process of locating logical and run time errors in a function by stepping through the source code one line (or several lines) at a time, while simultaneously examining the path of program execution and the values of variables used in the function.

This tutorial will introduce you to Origin’s debugging tools and cover basic Origin C debugging techniques.


Configuring Code Builder for Debugging

Origin includes an Integrated Development Environment (IDE) named Code Builder. Code Builder is launched from Origin by clicking the Code Builder button [image] on the Standard toolbar. Code Builder is an multiple document interface (MDI) capable of opening any number of text files at one time.

In addition to the Code Builder multiple document interface (MDI), where opened files can be seen and edited, there are a number of dockable tools which perform different functions. These tools include the Workspace window, the LabTalk Console (or Command & Results window), the Output window, the Watch window, The Local Variables window, and the Call Stack. These tools can be launched from the Code Builder View menu. The objective of this tutorial is to demonstrate how several of these windows can be used together to aid in the development and debugging of Origin C programs.

How each user sets up Code Builder for debugging is, to a large extent, a matter of personal preference but there are a number of key elements. To get ready for a debug session follow the steps below.

  1. Click the Code Builder button [image] on the Standard toolbar.

  2. From the Code Builder menu, select File:New Workspace.

  3. Click the Open toolbar button [image].

  4. Browse to and open the file \Tutorial\DebugTutorial.c., in the Origin program folder.

  5. Activate the DebugTutorial.c window in the Code Builder workspace and press CTRL+W to add the file to the current Code Builder workspace.

Note: Files can be open in the Code Builder workspace without being added to the “workspace” and files can be added to the Code Builder “workspace” without being opened. Files open in the workspace are available to be edited and files added to the workspace are compiled when the workspace is re-built. Open files are not compiled unless they are also added to the workspace; Added files are always compiled regardless of whether or not they are open.

  6. Click the Rebuild All button [image] to compile, load, and link DebugTutorial.c

  7. Select the View menu as needed to open the Workspace window, the LabTalk Console, the Local Variables window, and the Call Stack.

A check mark next to a View menu item indicates the window (dockable tool) is open. Docked tools can be undocked and floated by double-clicking on the two vertical bars at the left side of the window. Undocked or floating tools can be docked by double-clicking on the title bar of the tool.

  8. Make sure the Debug toolbar is visible by selecting theTools:Customize menu item and checking the Debug checkbox on the Toolbars tab.

The Debug toolbar can also be docked and undocked by double clicking on it.


Getting Started

  1. Activate the DebugTutorial.c window in Code Builder. Near the top of the file locate and click on the line:

double dDelta, dTol;

You can position the cursor anywhere on the line.

  2. Select the Debug:Toggle Breakpoints menu item. A brown circle is displayed in the gray margin to the left of the above line indicating that a debug breakpoint has been set for that line.

  3. Toggling the breakpoint on and off a few times by repeating the last step. Leave the breakpoint on (set) before continuing.

Note: Most Debug commands can be executed by selecting a Debug menu item, by pressing special keyboard shortcut keys, or by clicking a button on the Debug toolbar. This tutorial will use each of the methods at different times but will most often use toolbar buttons. The Debug menu contains all menu items and lists equivalent shortcut keys and Debug toolbar buttons indicate functionality by icon and by tool tips activated by holding (but not clicking) the mouse cursor over the button.

  4. Locate the LabTalk Console (Command & Results window) and type the name of the function that you want to debug:

DebugTutorial

  5. Press ENTER.

The Origin C function is executed but program execution is temporarily suspended at the line of code containing the breakpoint. Debug mode and the current point of program execution are indicated by the Debug Cursor, represented by a yellow arrow.

  6. Select the Debug:Step Into menu item. Note that one line of code (the one containing the break point) was executed and then execution stopped again on the next line. Notice the yellow arrow has progressed to the next line indicating that line will be executed next.

  7. Activate and examine the contents of the Local Variables window. Size and position the Name and Value columns by resizing the tool and by dragging the column header separation line so that the contents of both columns are completely visible.

Note that the variables dDelta and dTol are listed and their values are initialized to 0. The Path of program execution has so far only executed their declaration statement, so only these two variables are displayed.

This tutorial is continued in the next section, Go, Step Into, Step Over, and Step Out.


Go, Step Into, Step Over, and Step Out

  1. While still in the same Debug session, click on the line:

i2 = vUniform.GetSize() - 1; //…

  2. Press the F9 function key to set a second breakpoint further down in the file.

  3. Click the Go (to Origin) button [image] on the Debug toolbar.

The Go button causes program execution to continue to the next breakpoint in the path of execution. If there are no breakpoints in the path of execution, then the program runs until the function completes, Debug mode is exited, and control is returned to the Origin or Code Builder user interface. Since we added a breakpoint program execution stops at the next breakpoint as indicated by the new position of the Debug Cursor.

  4. Activate the Local Variables window again and note the additional variables that have been added and the values that have been updated according to the path of execution.

  5. Click the [+] plus sign next to the vector vNotUniform and note the vector expands showing all 21 elements and their values.

  6. Activate the Watch window (View:Watch). Size and position the Name and Value columns by resizing the tool and by dragging the column separator so that both columns are clearly visible.

  7. Double-click on the first row in the Name column and enter:

i2

  8. Double-click on the second row in the Name column and enter:

vUniform

  9. Click the Step In button [image] on the Debug toolbar.

Note that the values of i2 and vUniform are displayed in the Watch window. The Watch window is similar to the Local Variables window except that only entered variables in program scope are displayed.

  10. With the cursor on the line:

bVectorIsUniform = …

  11. Click the Step In button [image] once again.

Note that program control has stepped “In” to a newly called function named VectorHasUniformSpacing.

  12. Repeatedly click the Step In button [image], noting the path of program execution and the contents of the Local Variables window stopping after the for loop is entered but before it is exited.

Especially note blocks of code in the path of execution that get executed, skipped, or repeated depending on the result of the flow control statements (if, else, for, return, etc.) in the source code.

  13. Select the View:Call Stack menu item and note its display of function calls and line numbers.

  14. Click the Step Out button [image] on the Debug toolbar and note that program execution is passed back to the DebugTutorial function. Note the Call Stack window updates.

  15. Click the Step Over button [image] on the Debug toolbar three times noting that this time the function call to VectorHasUniformSpacing is not stepped into. It is executed but it is stepped “Over.”

  16. Click the Go (to Origin) button [image] or the Stop Debugging button [image] on the Debug toolbar. If you click the Go to Origin button the DebugTutorial function terminates normally and if you click the Stop Debugging button program execution is halted immediately.

This completes the tutorial, Debugging Origin C Files Using Code Builder.


Tutorial 17, The Code Builder Workspace

In this exercise, we will create a workspace, add a source file with a new function, then build, test and save the workspace file.


The Workspace File

A workspace is a collection of files that can be opened by a single menu option (File:Open Workspace …) in Origin’s Code Builder. Any text file can be a part of the collection. They do not necessarily have to be source code files; they could be notes, for example.

All files opened in the Multiple Document Window by a workspace can be edited and saved individually. In addition to files being opened in the Multiple Document Window, source code files can be added to the Workspace Window with the File:Add to Workspace menu option.

By including source code files in the Workspace Window, you can build individual or multiple files with the appropriate menu option or tool. Header files can be referenced within source files and do not need to be loaded in the Workspace Window or even open in the Multiple Document Window.

Since you can save a workspace with a new name, you can have multiple workspace files. However, only one workspace file can be open at a time.

To create a workspace:

  1. On the Standard toolbar, click the Code Builder button [image].

  2. From the Code Builder menu, select File:New Workspace. This creates a new workspace with the default name of “Untitled.ocw”.

  3. From the Code Builder menu, select File:New. This opens the New File dialog.

  4. Choose C File, and type foo in the File Name text box. The Add to Workspace and Fill with Default Contents check boxes should be selected. You may accept the default Location. Click OK.

  5. In FOO.C, starting below the line that says ‘\\start your functions here”, type the following:

void bar()

{

printf("Hello World!\n");

}

  6. Click the Build button [image]. Origin automatically saves the source file and compiles and links the function.

  7. From the Origin menu choose Window:Script Window.

  8. To test our new function, type:

bar

  9. Press ENTER

Origin responds by typing Hello World!!!

  10. From the Code Builder menu, choose File:Save Workspace As….

The figure shows the FOO.OCW workspace file containing a single source file, FOO.C, in the Multiple Document Window. The file has been added to the Workspace Window. The Output Window shows that the file has been compiled. The source file contains a single function – bar( ) – which is listed in the tree structure of the workspace.


Workspace Folders

The Code Builder workspace has four subfolders named Project, System, Temporary, and User. Files added by user, such as foo.c that you just added, are placed in the User subfolder. Origin, itself, uses Origin C for many analysis routines. When these routines run, the Origin C source files are loaded into the Workspace into either the System subfolder or the Temporary subfolder. The Project subfolder is reserved for files that are saved and loaded with the Origin project. This aspect of attaching a file to the project is described in a separate tutorial.


Build on Startup

Also on the shortcut menu of the Origin C Workspace filename is the Build on Startup option. When this is checked, the last workspace you saved will be loaded when you restart Origin. All source files in the Workspace will be built and all functions in the source files will be available for immediate use.

For information on building individual source files on startup by including information in the ORIGIN.INI file, go to Help:Programming and search on “.INI.”

This concludes the tutorial on the Code Builder Workspace.


Tutorial 18, Organizing and Accessing Origin C Functions

In this tutorial, we look at ways in which you might call your Origin C functions.


Saving your Origin C Function with your Project

One way to load and compile your Origin C function is to save the Origin C file as an attachment to your Origin Project (*.OPJ) file. When a project file is opened, all files attached to it are separated out and store in a temporary folder. In addition, any Origin C file that was attached is also automatically loaded into the Code Builder workspace, and compiled. The function is then ready to be called upon opening the Origin Project file.

  1. Start a new Origin project file by clicking on the New Project button [image] on the Standard Toolbar.

  2. On the Standard Toolbar, click the Code Builder button [image].

  3. From the Code Builder menu, select File:New. This opens the New File dialog box.

  4. In the top list-box, select C File.

  5. In the File Name text box, type: Test. Click OK. The file Test.c is added to the workspace.

  6. Select and copy the following function, and paste it into the Test.c file. Be sure to paste the text below the line that reads “//start your functions here.”

void Plot_Data(string strTemplate, string strData)

{

GraphPage grph;

// Create a graph window from a Template

BOOL bOK = grph.Create(strTemplate, CREATE_VISIBLE);

if (!bOK)

return;

// Attach the first layer (0) to a new GraphLayer object

GraphLayer grlay = grph.Layers(0);

Curve cv(strData);

//Attach a dataset to a new Curve object

// Add the Curve object to the GraphLayer object

int nPlot = grlay.AddPlot(cv);

if(nPlot>=0)

{

// Set plot color to Green (2)

grlay.DataPlots(nPlot).SetColor(2, TRUE);

grlay.Rescale(); // Rescale the plot

}

}

The Plot_Data function takes two arguments: (1) the template name and (2) the name of a Y dataset to include (plot) in the layer.

  7. Click the Build button [image] to compile and link the file.”

  8. Drag-and-drop the file Test.c from the User subfolder branch of the Workspace tree, to the Project subfolder. (Hint: You may need to first expand the User subfolder branch to display the Test.c entry prior to dragging the file).

  9. Go back to the Origin interface and save the project by clicking the Save button [image] on the Standard Toolbar. Give the project the name Test.OPJ, and save it in a location of your choosing.

  10. The Origin C file, Test.c, is now saved with the Project. To verify this, close the project, and go back to Code Builder. You will see that there are no entries under the Project subfolder of the Workspace tree. Now go back to Origin interface and reopen the project. Go to Code builder and verify that Test.c is now listed under the Project subfolder (Hint: you may need to expand the Project subfolder branch to see the Test.c entry).


Associating your Programs with Visual Objects

You will now learn how to create a button on a worksheet and program the button to call the Origin C function in the Test.C file that you save with the project.

  1. Open the Test.OPJ project that you saved under step 9 (previous section).

  2. Highlight the A(X) and B(Y) columns, right-click and select Fill Columns With:Row Numbers.

  3. From the menu, select Format:Worksheet to open the Worksheet Display Control dialog box.

  4. In the Worksheet Measurement group, set the Gap from Top to 40 and click OK to close the dialog.

The worksheet now has sufficient space above the column headings to add a text label.

Right-click in the area directly above the two columns and choose Add Text.

  5. At the cursor, type: Plot Data.

  6. Click once outside the text label to deselect it.

  7. Right-click on the text label and choose Label Control, to open the Label Control dialog box.

  8. From the Script, Run After drop-down list, choose Button Up.

  9. Type the following script in the text box at the bottom of the dialog box:

Plot_Data("scatter","data1_b");

  10. Click OK.

Your text label will now look like a button.

  11. Click the Plot Data button on your worksheet.

  12. The Plot_Data() function in your Test.c file is called, and a scatter plot is created.

Note: The script behind the button assumes that you have data in column B(Y) of the Data1 worksheet and that there is an associated X data set.


Loading and Compiling your Origin C Function from script

In this tutorial we learned how to save an Origin C function along with the project file and then access the function from the Origin interface. Saving an Origin C file with a project limits access to functions within that file to only that project. When a new project is opened, the functions are not available any more.

To access functions in an Origin C file that is saved on disk, the file can be programmatically loaded and compiled using LabTalk script. The script command for for performing the programmatic load and compile is run.LoadOC. Refer to the Programming Help files (Help:Programming) for more information on using this command.

This concludes the Origin C Functions tutorial.


Tutorial 19, Calling NAG Functions From Origin C

Calling a NAG function from an Origin C function is very much like calling any other Origin C function. You must familiarize yourself with the desired NAG function to gain an understanding of what parameters the function requires to be passed as arguments and what parameters the function returns. Once familiar with the function, you must develop code that follows the function’s requirements.

The NAG header file containing the function’s prototype must be included, required parameters must be correctly declared, sized, and initialized, and the function call must follow the function’s prototype as described in the Origin C Language Reference. The objective of this tutorial is to demonstrate how to call a NAG function from an Origin C function.


Understanding NAG functions

The primary resource for understanding Origin C NAG functions is the Origin C Language Reference. The Origin C Language Reference contains an entry for each NAG function that includes a description of the function, the function’s prototype, the name of the NAG header file containing the function’s prototype, and a description of all arguments (both input and output) required by the function. Sample data and an example program calling the function are also often included.

  1. From the Origin menu select the Help:Programming and go to the Origin C Language Reference section (or from the Code Builder menu select the Help:Origin C Language Reference

  2. In the Origin C Language Reference expand the Origin C Documentation book, expand the Global Functions book, expand the NAG Functions book, expand the NAG - Regression Analysis book, and then select the function nag_regsn_mult_linear.

  3. Study the nag_regsn_mult_linear function as needed to understand the required parameters.

Secondary resources for understanding the Origin C NAG functions include the Origin C NAG header files located in the …\Origin\OriginC\system\NAG subfolder and a collection of NAG PDF files located in the \Origin\NAG PDFs subfolder.


Getting Ready to Debug Sample Code

The best way to understand how to write an Origin C function that calls a NAG function is to step through an example function in Debug mode. Follow the steps below to set up Origin and Code Builder to execute such a sample Origin C function in Debug mode.

  1. On the Origin Standard toolbar, click the Open button [image].

  2. Browse to the \Tutorial folder and open NAGTutorial.OPJ.

  3. On the Standard toolbar, click the Code Builder button [image].

  4. From the Code Builder menu, select File:New Workspace.

  5. From the Code Builder Standard toolbar, click the Open toolbar button [image].

  6. Browse to the \Tutorial folder and open the file NAGTutorial.c.

  7. In the Code Builder IDE, activate the NAGTutorial.c window (click on the window) and press CTRL+W to add the file to the workspace.

  8. Click the Code Builder Rebuild All button [image] to compile, load, and link NAGTutorial.c.

  9. From the Code Builder menu, select View and verify that the LabTalk Console (Command & Results) and the Local Variables windows are open (the menu item is selected).

  10. From the Code Builder menu, select Tools:Customize and verify that the Debug and Search toolbars are selected.


Including the NAG Header

  1. Activate the NAGTutorial.c window in Code Builder. Near the top of the file, above the function NAGTutorial, locate the line:

#include <NAG\OCN_g02.h> // NAG function

  2. Right-click anywhere in the line and select Open “NAG\OCN_g02.h”.

This opens the header file containing the prototype for the NAG function nag_regsn_mult_linear.

  3. In the Search combo box, type the following:

int nag_regsn_mult_linear(

  4. Press ENTER.

The Code Builder editor scrolls to the line containing the above text. The NAG header file containing the function prototype of the NAG function you want to call must be included in your source file above the line where the NAG function is called. The name of the NAG header file containing the prototype for each NAG function is listed under the function in the Origin C Language Reference section of the Programming Help file.


Stepping Through a Sample Function in Debug Mode

  1. Reactivate the NAGTutorial.c window in Code Builder. Near the top of the file, inside the function NAGTutorial.c, locate the line:

int iErr;

  2. Position the cursor anywhere on the line.

  3. Click the Toggle Breakpoint button [image].

A brown circle displays in the gray margin to the left of the line indicating that a Debug breakpoint has been set for that line.

  4. Activate the LabTalk Console (Command & Results window) in Code Builder and enter

NAGTutorial

  5. Press ENTER to execute the sample function having that name.

The function NAGTutorial is an Origin C wrapper function that is used to set up variables and to call a more general Origin C function named nt_multiple_linear_regression that in turn calls the NAG function.

  6. Step through each statement in the NAGTutorial function by repeatedly pressing the Step Into button [image] on the Debug toolbar.

Be sure to stop along the way to read the comments for each statement. Also, periodically re-size and re-position the Local Variables window and view the current run time value of each variable as it gets set.

  7. Stop when you reach the following line:

The line above calls an Origin C function named nt_multiple_linear_regression that in turn calls the NAG function.

  8. Press the Step Into button [image] once more to step into the function nt_multiple_linear_regression.

  9. Continue stepping through each statement in the nt_multiple_linear_regression function one line at a time by repeatedly pressing the Step Into button [image] on the Debug toolbar.

Be sure to stop along the way to read the comments for each statement as needed to understand the code. Also, periodically re-size and re-position the Local Variables window and view the current run time value of each variable as it gets set.

  10. Stop when you reach the line that begins with the following:.

This is the line of code that calls the NAG multiple linear regression function named nag_regsn_mult_linear.

  11. Press the Go button on the Debug toolbar to finish executing all code in the NAG Tutorial example.

The example functions complete execution and the equation generated by the multiple linear regression is typed out in the bottom pane of the LabTalk Console (Command & Results). Note that it is the same equation used to generate the sample data.

This concludes the NAG Functions tutorial.


Tutorial 20, Accessing Internal Origin Objects

Internal Origin objects (such as Project Explorer folders, Origin windows (pages), layers, plots, graphic objects, data sets etc.) are accessed using Origin C classes. To access or programmatically control an internal Origin object you must attach it to an Origin C object.

To attach to an internal Origin object you must first “find” it using the properties, methods, and collections of a container class. Common container classes include the Project, Folder, Page, GraphPage, Layer, GraphLayer, Worksheet, MatrixLayer, and Collection classes. Once found, an internal Origin object can easily be attached to an Origin C object of the appropriate type.

The internal Origin object is then programmatically controlled by manipulating the class methods and properties of the attached Origin C object. The objective of this tutorial is to demonstrate how to find particular internal Origin objects, attach to those objects, and to access the objects by manipulating the methods and properties of the attached Origin C objects.


Accessing Worksheet Related Objects

Familiarity with the Origin C Project class (PROJECT.H), the Collection class (COLLECTION.H), and the Folder class (FOLDER.H), is valuable when attempting to understand how to find particular internal Origin Objects. User’s may find it helpful to preview these classes in the Classes book of the Origin C Help Reference or in the above header files located in the ..\Origin\OriginC\system subfolder. If you are not familiar with debugging Origin C files in Code Builder you may also find it helpful to review the Debug Tutorial before proceeding.

To begin this tutorial:

  1. On the Standard toolbar, click the New Project button [image].

  2. On the Standard toolbar, click the Code Builder button [image].

  3. On the Code Builder menu, select File:New Workspace.

  4. On the Code Builder menu, click the Open button [image].

  5. Browse to the \Tutorial folder in the Origin software directory, select AccessWorksheetObjectsTutorial.c, select the Add to Workspace check box and click Open.

  6. On the Code Builder toolbar, click the Rebuild All button [image]. This compiles and links the file.

  7. On the Code Builder View menu, verify that the LabTalk Console (Command & Results) and the Local Variables windows are visible (the menu item is checked).

  8. From the Code Builder menu, select Tools:Customize. Select the Toolbars tab and make sure that the Debug toolbar check box is selected.

  9. In Code Builder, activate the AccessWorksheetObjectsTutorial.c.

  10. Near the top of the file locate and click on the line:

PageBase pb;

You can position the cursor anywhere on the line.

  11. From the Code Builder menu, select Debug:Toggle Breakpoints. Alternately, press F9 or click the Toggle Breakpoint button [image] on the Debug toolbar.

A brown circle is displayed in the gray margin to the left of the line indicating that a Debug breakpoint has been set for that line.

  12. In the Code Builder workspace, activate the LabTalk Console (Command & Results window) and type the following:

AccessWorksheetObjectsTutorial

  13. Press ENTER to execute the function.

  14. On the Debug toolbar, press the Step Into button [image].

  15. Press the Step Into button [image] repeatedly, stopping to read the comments for each statement. Periodically stop and re-size and/or re-position the Local Variables window to view the current runtime value of each variable.


Accessing Graph Related Objects

  1. Return to the Origin workspace and, on the Standard toolbar, click the Open button [image].

  2. Browse to the \Tutorial subfolder, select AccessGraphObjectsTutorial.OPJ, and click Open.. You may be prompted to save changes to an untitled project. Click No and a worksheet and graph should open.

  3. From the Code Builder menu, select File:New Workspace. Click No when prompted to save workspace changes.

  4. In Code Builder, click the Open button [image].

  5. Browse to the \Tutorials subfolder, select AccessGraphObjectsTutorial.c, select the Add to Workspace check box, and click Open.

  6. Click the Rebuild All button [image] to compile and link the file.

  7. On the Code Builder View menu, verify that the LabTalk Console (Command & Results) and the Local Variables windows are visible (the menu item is checked).

  8. From the Code Builder menu, select Tools:Customize. Select the Toolbars tab and make sure that the Debug toolbar check box is selected.

  9. In the Code Builder workspace, activate the AccessGraphObjectsTutorial.c.

  10. Near the top of the file locate and click on the line:

GraphPage gp;

You can position the cursor anywhere on the line.

  11. From the Code Builder menu, select Debug:Toggle Breakpoints. Alternately, press F9 or click the Toggle Breakpoint button [image] on the Debug toolbar. A brown circle is displayed in the gray margin to the left of the above line indicating that a Debug breakpoint has been set for that line.

  12. Activate the LabTalk Console (Command & Results window) in Code Builder and type the following:

AccessGraphObjectsTutorial

  13. Press ENTER to execute the function.

  14. On the Debug toolbar, press the Step Into button [image].

  15. Press the Step Into button [image] repeatedly, stopping to read the comments for each statement. Periodically stop and re-size and/or re-position the Local Variables window to view the current runtime value of each variable.

This concludes the Internal Origin Objects tutorial.


Tutorial 21, Automation Example

In this simple example, we import an ASCII file, create a graph with data from the ASCII file, perform a nonlinear curve fit on the data, and export the graph with the resulting best-fit curve and a label reporting fitting results to a .BMP file.


Automating a Repetitive Routine

If your analytical work involves a lot of repetitive tasks, you might consider automating your routines. To find out how such automation routines can be linked to a toolbar button, search on “New Toolbar Buttons” in the Origin Programming Help file (Help:Programming). For a more elaborate automation and batch processing example, see the sample project \Samples\Programming\Automation\Automation.OPJ.

To begin this tutorial:

  1. On the Standard toolbar, click the Code Builder button [image].

  2. From the Code Builder menu, select File:Open.

  3. Browse to the \Tutorial folder and open Automation.c

  4. From the Code Builder menu, select File:Add to Workspace.

  5. On the Code Builder Standard toolbar, click the Build button [image].

The Output Window reports “Done!” when the compile competes.

  6. Return to the Origin workspace. From the menu, choose File:New Project.

  7. From the menu choose Window:Script Window and type the following:

Process %yTutorial\Sample.txt

Origin stores the software directory path in the system variable %y. The string %yTutorial\Sample.txt points to the file Sample.txt in the \Tutorial subfolder. The function Process( ) which is coded in the Automation.c reads this file name and does the following:

  • The file is opened.

  • A new worksheet is created.

  • The ASCII file is read and the xy data are imported into the first two columns of the worksheet.

  • A graph is created using this xy data.

  • A nonlinear curve fit is performed on the plotted data.

  • The resulting graph, with the best-fit curve and fit results, are exported to a BMP file. The file, named AutomationTutorial.BMP, is saved to the \Tutorial subfolder.

This concludes the Automation Example tutorial.


Tutorial 22, Programming Cues to Enhance User-Friendliness

Whenever a program user takes some action, it is advisable to provide some kind of feedback to the user. If you create code that takes a while to execute, you should provide some indication that the code is working and – if possible – display partial results.

This tutorial demonstrates some standard techniques – varying the Mouse Pointer, using output messages, showing a progress box, and gradual graph updates – for providing user feedback during program execution.


The Wait Cursor

One standard Windows technique is to change the mouse cursor to a Busy cursor. Typically, this is an hourglass, but the cursor can be customized on most systems. The Busy cursor will appear over the application that created it until the application changes it back to the Normal Select cursor.

You can invoke this cursor in Origin C by using a waitCursor object.

To begin this tutorial:

  1. Click the Code Builder button [image] on the Standard toolbar.

  2. From the Code Builder menu, select File:Open, browse to the Origin\Tutorial folder and open User Friendly Interface.c.

  3. To add this file to the workspace, select File:Add to Workspace.

  4. Click the Build button [image]. The Output window reports “Done!” when the compile completes.

  5. Return to the Origin workspace and open a New Project (File:New…Project).

  6. Open the Script window (Window:Script Window) and type the following:

BusyAsABee()

  7. Press ENTER.

When you execute the BusyAsABee function, you are calling the following section from the C file. Note the comments (the green text with leading //).

Origin will add columns to the active worksheet until 10000 columns have been added or you press the Escape key. While the program is executing, the Mouse Pointer will display the Busy cursor over Origin, and a message is displayed in the Data Display window indicating the current new column.

This tutorial continues with the following section, The Progress Box.


The Progress Box

Another programming technique that can be particularly useful when you know how many steps you will take – but you don’t know how much time each step will take to execute – is to provide a progress box to indicate a percent of completion. You can use Origin C to display a Progress Box while your program executes, and update the progress indicator as needed.

This portion of the tutorial assumes that you have the “User Friendly Interface.c” file loaded and compiled from the previous example.

  1. Type the following in the Script Window:

Progress(100,0)

  2. Press ENTER.

When you execute the Progress function, you are calling the following section from the C file. Note the comments (the green text with leading //).

A progress box will display with a bar and number indicating percent of task completion. The percent is calculated automatically from the beginning, current and end values. Pressing the ESC key or clicking the Cancel button will close the box after the current step completes.

This tutorial continues with the following section, Graph Updates.


Graph Updates

If you have a calculation that takes a long time to build a dataset that you want to graph, you don’t have to wait to display the entire graph. You can update the graph in segments.

The RealTimeDisplay() function in the “User Friendly Interface.c” file illustrates the technique.

This portion of the tutorial assumes that you have the “User Friendly Interface.c” file loaded and compiled from the previous example.

  1. Type the following in the Script Window:

RealTimeDisplay()

  2. Press ENTER.

When you execute the RealTimeDisplay function, you are calling the following section from the C file (only partially displayed here; see the .C file for the full code). Comments are the green text with leading //.

A worksheet and a graph will be created and the graph will be updated in pieces. Note that there is also code which will display a progress box as well.

  3. Return to the Code Builder interface and uncomment the four lines which are marked with “UNCOMMENT FOR PROGRESS BOX DISPLAY” (Remove the leading // from the 4 lines of code, but do not remove them from the four “UNCOMMENT FOR PROGRESS…” comments). Your code should now look like this:

  4. Click the Re-build button [image].

  5. Return to the Origin workspace and enter the following into the Script window:

RealTimeDisplay()

  6. Press ENTER.

Note how the graph and the progress box seem to update simultaneously.

This concludes the Programming Cues tutorial.


Tutorial 23, Advanced Scripting using LabTalk

This tutorial demonstrates using some advanced LabTalk scripting commands and methods to organize your script files. To learn more about all the commands and methods supported in LabTalk, please refer to the LabTalk Language Reference section of the Programming Help files.


Modifying Plot Attributes via Script

This section demonstrates how to use script commands to change the attributes of a data plot.

  1. Start a new project, enter the numbers 1 through 5 in column A of the Data1 worksheet and numbers 6 through 10 in column B. If you have not already done so, open the Script Window by selecting Window:Script Window from the Origin program menu.

  2. Using the worksheet data from the previous exercise, create a scatter plot. Note that the scatter plot symbol is a black filled square (symbol size is increased for clarity).

  3. To change the symbol shape, type the following:

set %C -k 2

  4. Press ENTER.

The data plot symbol changes from a filled square to a filled circle (the numbers correspond to Origin's symbol list; 1 = square, 2 = circle, etc.).

  5. To change the symbol color, type the following:

set %C -c 2

  6. Press ENTER

The data plot symbol color changes from black to red.

To modify the axis scale values

  7. Type the following:

X1=0;X2=20;Y1=0;Y2=10

  8. Press ENTER.

Your X axis scale now reads from 0-20; the Y axis reads from 0-10.

Note: As this example illustrates, you can type multiple lines of script on a single line by separating commands with a semi-colon.

You can also use the set command to specify the data display range.

  9. Type the following:

Set %C -b 2

  10. Press ENTER

The graph’s display range now begins with the second data point in the dataset.

  11. Type the following:

Set %C -e 4

  12. Press ENTER

The graph’s display range now ends with the fourth data point in the dataset.

You can also hide or show a data plot using the set command’s -s switch.

  13. Type the following:

Set %C -s 0

  14. Press ENTER.

The active dataset is now hidden.

  15. To show the hidden dataset Type:

Set %C -s 1

  16. Press ENTER.


Defining a LabTalk Script Macro Command

A macro is a convenient method of aliasing a LabTalk script. When you define a macro you are associating an entire script with a specific name. This name becomes a command that invokes the associated script.

When developing scripts, macros can provide several advantages.

  • Modular code can streamline a script by replacing repetitive or similar blocks of code with multiple calls of the same macro.

  • Modifications to your code become easier to implement because you only have to redefine your macro as opposed to modifying repeated blocks of code that are scattered throughout your application.

  • There is a limit to the number of tokens that can be included between a set of curly braces that enclose a script. Macros provide a means to shorten the code between braces by calling a pre-defined macro.

  • You can modify the behavior of a LabTalk command by creating a macro of the same name. The functionality of the LabTalk command is restored when the macro is deleted.


Defining a Macro

A macro is defined using the define command. The general syntax is,

define macroName

{

script

}

where macroName and script are the name of the macro and the body of the macro, respectively.

The define a macro using LabTalk’s define command:.

  1. From the Origin menu, select Window:Script Window.

  2. Type the following:

def hello {

type -b "Hello World!!!";

}

This script defines a macro named hello that will type "Hello World!!!".

Note: The define command can be abbreviated as def

We will now use the Script window to call our hello macro.

  3. Type the following into the Script window:

hello

  4. Press ENTER.

An attention dialog opens to say "Hello World!!!".


Origin’s Predefined System Macros

Let's look at Origin's predefined system macros, some of which take an argument. Macros can take up to five arguments. Use the %1, %2,… %5 notation within the script definition to indicate that the macro expects one or more arguments (%1= 1st argument, %2= 2nd argument,…%5 = 5th argument).

  1. In the Script window, type the following:

list m

  2. Press ENTER.

Origin responds by typing the names of predefined macros to the Script window.

0 ARRANGELAYERS

1 BEFOREITERATE

2 BEGINSAVE

3 CHECKMARGINS

4 CHECKVAR…etc.

To see the definition of any system macro:

  3. To see how a system macro is defined, type Def macroname. For example, type the following in the Script window:

Def graph

  4. Press ENTER.

Origin responds by typing the following to the Script Window:

def graph;

{

set %1 -s 1;layer -i %1

}

The %1 notation in the macro definition indicates that this macro takes one argument.

Note: Recall that in Tutorial 9, we used the set dataset –s 1 command to show a data plot. The layer -i dataset command adds (plots) the named data set to the active layer.

To call a macro:

  5. Click the New Worksheet button [image].

  6. Create a worksheet named Data1 and type in the following data:

  7. Click the New Graph button [image].

  8. In the Script window, type the following:

Graph data1_b

  9. Press ENTER.

A line plot of dataset data1_b is included in the graph window.

We will modify the macro definition so that it creates a scatter plot using a symbol type of red, “up triangle.”

You could hard code the appropriate values for scatter plot, red, and up triangle in the macro definition but it is more efficient to pass the value of a variable as an argument. In this way, the macro may be used in other instances where you want to set the color and symbol shape to something other than red, upward-pointing triangle .

Note: LabTalk often uses an integer value to specify plot details. If you look at the color palette, for instance (from the menu, Format:Color Palette), you will see (assuming that you have not modified the default color palette) that black =1, red = 2, green = 3, blue = 4, etc. For more information, see documentation on the Set command in the LabTalk Language Reference section of the Programming Help file.

  10. Type the following in the Script Window:

def graph

{

set %1 -s 1;layer –i201 %1;

set %1 -c %2; set %1 -k %3;

}

  11. Type the following:

graph data1_b 2 3

  12. Press ENTER.

This plots the data set data1_b as red, upward pointing triangles.

To better understand what we actually did, let’s examine our macro line by line.

First, we used the def command to tell Origin that we are defining a macro.

def graph

Secondly, we used the LabTalk set command with a – s option. The set –s command syntax is,

set dataset -s value

where dataset is the name of a data set, and value is either 1 (show plot) or 0 (hide plot),

{

set %1 –s 1;

The layer –i# command syntax is:

layer –igraphType dataset;

Note that the data set name has been assigned to %1.

The set –c command syntax is:

set –c color#

This is used to specify the plot symbol color. Note that color will be assigned to %2.

The set –k command syntax is:

set –k shape#

This is used to specify symbol shape. Note that symbol shape is assigned to %3.

When we execute our macro by typing,

graph data1_b 2 3

we are passing three arguments to the macro:

  • data1_b, which is substituted for %1.

  • 2, which is substituted for %2.

  • 3, which is substituted for %3.

Note that it is merely coincidence that we chose to substitute a value of 2 for %2, and a value of 3 for %3. We could have chosen any allowed value for symbol color or shape.

Remember that any macro that you define is only available for the duration of your Origin session. If you restart Origin, you cannot execute your macro until you define it again. If you want your macro to be defined automatically when you start Origin, you can save your macro definition to Origin’s MACROS.CNF file. Each time Origin starts, MACROS.CNF is read, and your macro is defined.

Note: MACROS.CNF is located in the Origin software folder. Because of a turf battle over the .CNF file extension, it will probably only be listed as MACROS and will display a terminal icon. In reality, this file is a text file and can be opened in any text editor, such as Notepad.

For more information on macros, see the LabTalk Language Reference section of the Programming Help file (Help:Programming).


Loading and Compiling your Origin C Function using LabTalk script

Before an Origin C function can be used, it must be compiled and linked in the current Origin session. Origin provides the following method to programmatically compile and link a source file, or to programmatically build a workspace, from LabTalk.

err = run.LoadOC("myFile",[option]);

Note: For more on the LabTalk run object in the LabTalk Language Reference section of the Programming Help file (Help:Programming).

The following example demonstrates how run.LoadOC is used in an existing Origin Project.

To begin, this tutorial:

  1. On the Standard toolbar, click the Open button [image].

  2. Browse to the \Samples\Programming\Bubble Sort subfolder in the Origin folder and open Bubble Sort.OPJ.

  3. On Graph1(Bubble Sort Demo), ALT + double-click on the Start button. This opens the Label Control dialog box.

  4. Scroll down through the script and take note of the following line:

if(run.LoadOC("%xBubble Sort.c") != 0)

  5. Click OK.

  6. Click once on the Start button.

Notice that the Bubble Sort.c function is now 'Loading and Compiling Origin C function'. The Origin C functions in Bubble Sort.C are now accessible.

  7. ALT+double-click on the Shuffle button to open the Label Control dialog box.

  8. Because this function has been compiled, it is recognized by Origin and is ready for use.


Using .OGS Files to Store Script.

As an alternative to associating your LabTalk script or Origin C function with a button, you could save your script to .OGS files. The advantage is that these .OGS files are self-contained and thus, could be called from many buttons.

These .OGS files are organized by sections. Sections are identified by a name surrounded by square brackets, as in this example:

[Main]

To execute the code in a portion of an .OGS file, you need only identify the .OGS file and refer to the containing section by name, as in this example:

run.section(test.ogs, Main)

Most of Origin's menu and toolbar commands run LabTalk script in an .OGS file. These files can be opened and edited in Code Builder.

In this tutorial, we will create a new OGS file, and associate the OGS file with a new toolbar button.

Note: This tutorial assumes that you have already created and saved an Origin C file called test.c, as prescribed under Tutorial 14: Organizing and Accessing Origin C Functions.

To create a new.OGS file:

  1. From the Code Builder menu, select File:New.

  2. In the New File dialog box, select LabTalk Script File.

  3. In the File Name text box, type:

Test

  4. Click OK.

You now have an empty document called test.ogs.

We will use the run.LoadOC script command to programmatically compile and link the test.C Origin C source file. The advantage of this method is that it allows you to program your buttons or other user-created visual objects to make behind-the-scenes calls to your Origin C functions.

To make a call to an “uncompiled” Origin C function from Origin:

  5. In the blank test.ogs window, type the following:

[CreateGraph]

run.LoadOC("test.c");

Plot_Data("scatter","data1_b");

  6. From the Code Builder menu, select File:Save As and save the file to your main Origin software folder.

  7. Return to the Origin workspace.

  8. From the Origin menu, select View:Toolbars. This opens theCustomize Toolbar dialog.

  9. On the Toolbars tab, click the New button to open the New Toolbar dialog.

  10. Type in the following name for your new toolbar::

My Toolbar

  11. Click OK.

My Toolbar is added to the Toolbars list. A new toolbar is added to the Origin workspace.

Note: The toolbar may be a bit hard to spot because it does not contain any buttons.

  12. Return to the Customize Toolbars dialog and select the Button Groups tab.

  13. Scroll to the bottom of the Groups list and select User Defined.

  14. Select the second button in this group.

  15. Click the Settings button. This opens the Button Settings dialog box

  16. In the File Name text box, type test.ogs.

  17. In the Section Name text box, type CreateGraph. We are not passing arguments to the section, so we can skip the Argument List text box.

  18. In the Tool Tip Text box, type CreateGraph. A Tool Tip is the message that displays when you mouse over a toolbar button.

  19. In the Status Bar text box, type Example, plotting data from Origin C' for Status Bar Text. When you mouse over a toolbar button, the Status Bar message displays in the lower left corner of your Origin workspace.

  20. In the Context group, verify that the Windows radio button is selected and clear the Graph, Matrix, Layout, and Excel checkboxes. Leave only Worksheet selected. This limits toolbar availability to active worksheets.

  21. Click OK.

  22. Point to the toolbar button, hold down the left mouse button and drag the button to the floating toolbar.

  23. Click Close to close the Customize Toolbar dialog.

To test this method, close and restart Origin. Remember that the second argument to our function is data1_b, so the Origin workspace will need to have a worksheet named data1, a B(Y) column and some data in both the X and Y columns. Note, too, that our toolbar button is grayed out when a graph is the active window.

This concludes the tutorial on Advanced Scripting Using LabTalk.