Anda di halaman 1dari 13

Intro

to Origin
Written by Norbert Mulders and used with his permission Origin is an enormously powerful piece of software used for data analysis. Many of its features will initially appear obscure, but some of Origins basic features are easily understood, and are of great use in introductory science courses. This tutorial/assignment will give you an opportunity to develop basic Origin skills. Parts are based on a much more extensive tutorial published by OriginLab. I have taken sections of that tutorial and added some comments. Formally there are three groups of skills that you should master: 1. Working with data files (called workbooks in Origin) Import data Create new data Modify data files Export data 2. Making graphs Graphing data in various formats Adding data to graphs Saving properly formatted graphs as template Exporting graphs as figures for other documents 3. Using Origin to analyze problems This often involves the use of the Differentiate and Integrate operations, as well as curve fitting. However, it should be clear that one uses these skills in a combined operation. There is no graph without data, and there is little point in data analysis if you cannot see the result (in the form of a graph). After mastering the basic skills, you should work through the section Doing Calculus with workbooks. This section shows how typical scientists use a program like Origin to solve problems. Finally there is the section Create an 8 layer multi-panel plot template. This section should teach you some more Origin skills. For the moment you can regard this as optional.

Making a simple graph


Workbook The Origin workbook is the primary structure for organizing your data. Each workbook is composed of one or more Origin worksheets. And each worksheet, in turn, is composed (usually) of one or more worksheet columns or datasets. Columns in Origin have different types, such as X, Y, Z, yError, etc, which represent the plot designation for graphing. To learn how to manipulate Origin workbooks, try the following: 1. Select File: New from the menu and choose Workbook to create a new workbook. 2. Select File: Import: Simple ASCII to bring up the Open dialog. Browse to the \Samples\Curve Fitting subfolder of the Origin program folder. Highlight the file Gaussian.dat and click the OK button to import the data into the Origin worksheet. 3. On import, sparklines were automatically turned on, allowing you to quickly view the shape of the data; the sheet name became the name of the file; and as needed an additional column was added to the worksheet. You can see from the Long Name that the 3rd column represents data error. To set this column as an Error Column, click the column title to highlight it, right-click to bring up a fly-out menu, and then select Set As: Y Error. 4. Plotting data in Origin is now easy; highlight all three columns and select Plot: Symbol: Scatter from the menu to create a scatter plot.

Comments: A. To use this method to work you must have created a new workbook first! If you have an already existing workbook active, the imported data will override the old data. This is rarely desirable. B. If instead of a workbook a graph is active, you can import data only through the Import Wizard. The data will be plotted directly in the active graph. This can be quite confusing when the data file contains more than one set of y-values. C. You can plot data by highlighting columns. Origin will then automatically use the X column as x-coordinate. This may not always be what you want. For example, you may have data for a rolling object. The data may contain the position as a function of time, as well as the potential and kinetic energy. This enables you to make a graph of Ekin as a function of time, but you could also plot Ekin as a function of position. In a case like that it is more convenient to make the graph by clicking on plot and selecting the type of graph you want to make. A panel, like the one shown below, shows up. This allows you to select x and y columns as you see fit.

D. Origin has as default graphs that show axes only at the bottom and the left of the graph. This is highly undesirable. You should add the top and right axes. To do this double-click on one of the axis. A panel appears that enables you to add axes using the Title&Format tab. Select one after another the missing axes, click on Show Axis & Ticks, and set the Major and Minor Ticks to in. 3

You do not want to do this for every graph that you make, so immediately save this format as template using File:Save Template As. A panel comes up like this.

Select Symbol as the category, and SCATTER as the Template name, and override the existing template. You can do something similar for the Line/LINE template.

How I usually make graphs


1. I open a new work book. 2. I import an ascii data file 3. I plot the data using Line or Symbol (as appropriate for the type of data). This allows me to select x and y columns as I see fit. Of course, you will develop your own preferred method.

Exporting a Graph
Normally, some of the graphs that you produce will be incorporated in a document. There are several ways to do this, we will address just two. The most basic one is to export the graph as an image file. What file format (image type) you choose will depend on the document you want to use it in. If you want to incorporate the graph in a Word document or a Power Point presentation you are best of selecting the Windows MetaFile format. This will produce a relatively small file with good graphics quality. To make this option permanent, click on Dialog Theme and select Save as <Default>. You have to tell Origin where and under what name to store the file. You may want to create a suitable directory to save graphs. You can make the path the default path again by clicking on Dialog Theme and selecting Save as <Default>.

The second option is to embed the graph in the target document. The simplest way to do this is to copy the page which contains the graph (select the page, not the graph itself) and to paste it into the document.

CTRL + C (Origin) => CTRL + V (MS Word). Edit:Copy Page (Origin) => Edit:Paste (MS Word).

This embedded graph can be modified. Simply click on the graph and Origin opens. You have to understand that the recipient of the document that you are assembling can also open the graph and modify it. This is not always desirable. Furthermore, an embedded file is often significantly larger than a simple Windows MetaFile. 5

Do the following: 1. 2. 3. 4. 5. Export the graph you just made in .wmf format. Create a word document. Insert a Text Box in that document. Insert: Picture: from file selecting the file you just saved. Right-click on the figure and select Insert caption A caption panel opens. As this is the first figure that have in your document the caption starts with Figure 1 you can complete the figure caption by typing more text now (or later). Click OK and you have a figure caption below your figure inside the textbox. (If you dont see the figure caption stretch the textbox.). The advantage of placing the figure in a textbox is that the textbox keeps the figure and the figure caption together. 6. Repeat this operation, but instead of using a previously saved file, embed the graph with a copy/paste operation. Verify that when you click on the graph another instant of Origin opens up.

Creating and Exporting Data


In the preceding section you have worked with data that imported from an existing file. In the following you will learn how to create data in Origin. Once again 1. Select File: New from the menu and choose Workbook to create a new workbook. The default workbook that opens up has two columns and 32 rows. Our aim is to make a graph of the function y = 3tanh ( 0.5 x ) . We want to do this for about 100 x-values with 5 x 5 . 2. First we create a column for x. Select the first column Right-click on the column and select set column values a panel opens that allows you to control the numbers of rows, and to set values. Let the row index i range from 1 to 101 (note i is a positive number) Generate a range of x values using the column index: 0.1*(-51 + i). this produces -5 for I = 1, 5 for I = 101, and 99 values in between. 3. Next we generate the y values Select the second column Right-click on the column and select set column values Generate a set of y values as 3*tanh(Col(A)/2) 4. Give the columns names like x and 3tanh(x/2) 5. Plot the data. You should end up with a workbook and graph that look like this

After convincing yourself that you generated the correct data, you can export the data. 6. With the workbook as active page, export the data using File:Export:ASCII to some data file. 7. Finally, create a workbook that contains values for sinh(x), cosh(x) and tanh(x) for the same range of x values as the previous exercise. You can simply copy the first column of the previous workbook and paste it into the new one. Then you add two more columns and set their values. Finally, plot the three hyperbolic functions in a single graph. Export the data as well as the graph.

Choice of Axes
It frequently happens that we would like to look at data that ranges over many orders of magnitude. We will see that under those circumstances graphs with linear axes are not very convenient, and that we should select logarithmic axes. The following should illustrate what these words mean. 1. Let us first generate x-values that span the range from 1 to something of the order of 109. We want to distribute the x-values such that for every decade of data we have the same number of points. Open a new workbook, and set the column values of the first (X) column using the formula (10^0.1)^(i-1). Do this for i ranging from 1 to 100. Convince yourself that this produces exactly ten x-values for every decade, starting with 1. 2. Now populate a number of columns with functions you are somewhat familiar with, such as ln(x), x, x2, x5 and ex. Make a symbol/scatter plot for ln(x). You already see that all the data is piled up on the left side of your graph, and it is difficult to see the details. Now add the data for the function y = x (and make sure you rescale your graph so you can see all data. The ln(x) data is now squeezed against the x-axes, and pretty much looks like zero. 3. To fix problems like this, select logarithmic axes. To do this double-click on one of the axes, and in the panel that comes up select the scale tab. Click on the Type drop down menu. Change the type from Linear to Log10. Do this for both axes. Now look at your graph again and be amazed. All he data is nicely displayed and the form of the function can clearly be seen. 4. Now add the y = x2 and y = x5 functions. Note that on log-log plots these functions are straight lines. Adjust the markings on your axes using again the scale tab and adjusting Increment. Verify that for the power law functions the slope of the straight lines is equal to the power of the function. The graph for y = x5 should go up by 5 decades in the y direction for every decade in the x direction. 5. Just for fun, add y = ex and note how much more rapidly this function increases that the power law functions. 6. Add the functions y = x0.1, y = x0.5 (the square root of x), and y = x1.5 to your work book. Make a new graph that contains these functions, as well as ln(x). Convince yourself that 1) that also for non-integer powers the slopes in a log-log plot are equal to the powers of the power law functions, and 2) that even a function like y = x0.1 eventually wins over the ln(x). 8

Doing Calculus with workbooks


As an example of what can be done with software like Origin, we will look at the problem of a falling object in the presence of air resistance. We want to know its position, velocity and acceleration as a function of time. The object we will drop is an aluminum sphere with a radius of 10 cm (4). The force on the sphere is given by
2 F = mg + 1 2 C Av

(1.1)

The first term is due to gravity, the second term represents the friction from the air, which is proportional to the velocity squared. m is the mass of the sphere, 11.3 kg C is a form factor, C = 0.47 for a sphere A is the cross sectional area of the sphere, A = 3.1410-2 m2 is the density of air, 1.3 kg/m3 The acceleration of the sphere is then

a = g v2

(1.2)

with = AC / 2m = 8.5 10 4 m1 . The terminal velocity, when gravity and friction balance each other and a = 0, is given by

vterm =

= 107 m/s

(1.3)

We drop the sphere from some height h0 and we would like to calculate h(t), v(t) and a(t). The problem is that to find h(t) we need to know v(t). To get v(t) we need a(t), but a(t) is a function of the still unknown v(t). What to do? (You may not be terrible familiar with the math that follows. Dont worry too much about that. This is an exercise to show the power of Origin, not that of Calculus.) We write eq. 1.2 as

dv = g v2 dt
This is a non-linear differential equation, but fortunately separable.

(1.4)

1 dv = dt g v2

g v
0

t 2

dv =

dt
0

(1.5)

The integral on the left hand side is a function of v, while the integral on the right hand side of the equation is just t. So we have a relation between t and v that reads t = f(v). We often write this simply as t(v), just as we would have written v(t) for the velocity as a function of time. Now let us solve the problem: 1. Start a new project 2. Fill the first column of Book1 with 108 values for v ranging from 0 to 107 m/s 3. Set the values of the second column equal to 1/a, i.e., values for g (9.8) and (8.510-4). 4. Label your columns and give them appropriate units. Proper labeling of your plot axes will then be taken care of automatically. 5. Plot 1/a as a function of v. 6. Select Analysis:Mathematics:Integrate. Nothing happens, but when you now look at your workbook you will note that a column has been added. It contains the integral. 7. Immediately change the name of this column to time and add units. 8. Plot v as a function of time, and note that the velocity does indeed go to a limiting value. 9. Now that you have a plot of v(t) you can find h(t) by integrating v(t). Origin now adds two columns. The first one is labeled Integral X, and duplicates the time. This always happens when the column with respect to which is integrated or differentiated is not of the X type. Just leave this column alone. The second column is the integral. 10. Plot h(t). 11. Go back to the v(t) plot and differentiate to get the acceleration. Again, two columns are added to your workbook. 12. Plot a(t) and note that it tends to zero. 13. Check your calculation. The last column that was generated is supposedly the acceleration, a. The second column in your workbook was set to 1/a. So the product of the second column and the last column should be one. Add one more column to your workbook, and set its values to the product of 1/a and a. You will see that only for later times the product deviates significantly from 1. This is due to the fact that the 1/a changes very rapidly for later times, and it becomes difficult to numerically integrate and differentiate. 14. You are now going to improve your calculation by reducing the step size in v from 1 m/s to 0.1 m/s. So instead of 108 data points you will have 1071 data points. It may sound as if you have to do everything over, but in fact very little work is involved. Select your first (v) column as set its values to (i 1)*0.1, with I running from 1 to 1071. Select the second column, select set column values again and click OK. Done with that column. The following columns all have all a little lock symbol on the topright side of the column. Click on it and select Recalculate. Only for the last column you may have to do a Set Column Value again. Note that you have now solved a not completely trivial problem without doing a single integral, etc., AND at the same time you have graphs of all your results so you can actually see what is going on. 10

(g v )

2 1

,with appropriate numerical

Create an 8 layer multi-panel plot template


This is copied straight from the OriginLab tutorial Summary All child windows in Origin, with the exception of the Notes window, are created from template files. These template files describe how to construct the window. For a graph window, the template file determines all page and layer characteristics, such as page size, number of layers, inclusion of text labels, data plot style information, etc. The template library lists all built-in as well as user-created templates. What you will learn How to create an 8 layer multi-panel plot How to save the formatting as a template How to reuse the template with similar data Steps

Choosing the Data Source 1. Click the New Project button on the Standard toolbar, to begin with a new project. 2. Click the Import Wizard button on the Standard toolbar. The Import Wizard opens. (Note that if this is the first time that you have started the Import Wizard, you will experience a slight delay as Origin compiles the necessary files.) 3. Verify that the ASCII radio button is selected in the Data Type group. 4. Click the browse button to the right of the File text box. Navigate to the Origin folder; browse to the Samples folder and then the Curve Fitting folder. Select Step01.dat from the list of files. 5. Click the Add File(s) button. 6. Click OK. 7. Leave the Import Filters for current Data Type as Data Folder: step. (This filter has the settings to use when importing the file.) 8. Click the Finish button. The data file imports into the worksheet.

Plotting the Data 1. Highlight the entire worksheet of data. (Note that you can select an entire worksheet by placing your cursor in the blank area in the upper left corner of the worksheet. When the cursor becomes a downward pointing arrow, click once to select the entire worksheet.) 2. Select Plot:Multi-Curve:9 Panel. A new 9 layer graph is created. 3. Select layer 9 by clicking inside it. 4. Press the Delete key on the keyboard. This will delete layer 9, leaving you with 8 layers. 5. Select Graph:Layer Management. The Layer Management dialog opens. 6. Select the Arrange tab. 7. Set Column to 2 and Row to 4. 11

8. Click the Arrange button. The preview in the dialog redraws to show you a 2x4 arrangement. 9. Click OK. Editing the Graph The goal is to save this 8 panel graph as a template; i.e. a new plot type, so that it can be used again with new similar data. Since the template will also save plot style information, let's customize the graph a bit further. 1. 2. 3. 4. 5. 6. 7. 8. Double-click on the X axis in layer 1. The X-Axis dialog opens. Select the Grid Lines tab. Check the Major Grids and Minor Grids checkboxes. Set the Line Color for both Major and Minor grids to LT Gray. Check the Apply To Grid Lines checkbox for This Layer. Click OK Select layer 1 by clicking inside it. Right-click inside the layer and select Copy Format:All Style Formats. This will copy the style formats of layer 1. 9. To apply formatting to all layers, right-click outside of any layer (make sure that no layer is selected...one easy way to do that is to right-click in the gray area of the window, outside the white printable part of page), and select Paste Format.

Saving as a new graph template 1. Select File:Save Template As. A dialog opens allowing you to choose the category that the template will be saved in as well as the name given to the new template. 2. Change the Category to UserDefined. 3. Change the Template Name from PAN9 to PAN8. (Note that the Template Name that appears when the dialog opens is the name of the original template that was used to create the graph.) 4. Expand the Option node and note that the template will be saved to your User Files Folder. 5. In the Description edit box, enter the following: My new 8 panel graph. 6. Click OK.

Plotting into your new template 1. Click the New Folder button on the Standard toolbar. 2. Click the Import Wizard button on the Standard toolbar. The Import Wizard opens. 3. Click the browse button to the right of the File text box. Navigate to the Origin folder; browse to the Samples folder and then the Curve Fitting folder. Select Step02.dat from the list of files. 4. Click the Add File(s) button. 5. Click OK. 6. Leave the Import Filters for current Data Type as Data Folder: step. (This filter has the settings to use when importing the file.) 7. Click the Finish button. The data file imports into the worksheet.

12

8. Highlight the entire worksheet of data. (Note that you can select an entire worksheet by placing your cursor in the blank area in the upper left corner of the worksheet. When the cursor becomes a downward pointing arrow, click once to select the entire worksheet.) 9. Select Plot:Template Library or click the Template Library button on the 2D Graphs toolbar. 10. Scroll down to the UserDefined category under Graph Template. 11. Select PAN8. (Note that the Preview window is not a preview of the new data that you are plotting. It is an image of the graph when you saved your template.) 12. Click Plot.

13

Anda mungkin juga menyukai