Showing posts with label Origin. Show all posts
Showing posts with label Origin. Show all posts

Thursday, June 25, 2009

OriginLab Settings for High Quality Graphs

This is a well overdue post. I know that some readers have been waiting for this. I apologize for the delay. I hope you'll find this talk useful.


Cite as:
Saad, T. "OriginLab Settings for High Quality Graphs". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/06/originlab-settings-for-high-quality.html

Saturday, February 7, 2009

Setting Column Values in Origin – the Programmers Way!

Do the following
  1. Select any of the columns by clicking on its title label
  2. Right click and invoke the “Set Values” dialog box
  3. Click on the little arrow to the bottom right (“Show Scripts”)
  4. In the “Before Formula Scripts” text box, type in the following:
    // set your reference paramters
    aRef = 10;
    aCorrection = 0.01;
    // loop over columns – say from column 2 to column 25 – you may need to start at column 2
    // since column 1 usually holds the data corresponding to the independent variable

    loop(i, 2, 25) {
    wcol(i) /= aRef;
    wcol(i) += aCorrection;
    }
  5. Click “Apply” or “OK”

Voila!

Origin is a “professional data analysis and graphing software for sicnetists and engineers”. More often than not, I find myself importing tons of data into worksheets. Most of the time, I would be comparing analytical (yes, some folks on this planet still do analytical work) and numerical data. Without loss of generality, most analytical solutions produce dimensionless data which will eventually end up being compared to numerical or experimental results. Of course, the numerical or experimental results need to be normalized accordingly. Bottom line, you have to go through every column of external data and do what needs to be done: divide, multiply, subtract etc…

In Origin, once you have some values in a column, you can right click on that column and select “Set Column Values” and enter some formula (e.g. Col(A) = Col(A)*10 + 2). The brute force approach is to go over every column, and type in the formula over and over again. So for Column B, you’ll have Col(B) = Col(B)*10 + 2 and so on.

Fortunately, Origin is amazingly modular and allows you to put in your formulas as a script. So here’s the idea: How about writing a script that loops over all the desired columns and sets the values accordingly?

The nice thing about this is that you can use the usual C operations: *=, /=, +=, and –=.

For online video tutorials and goodies related to Origin, check the OriginLab Website.

Enjoy programming!

Update: A couple of graphs made using Origin to illustrate the quality of the resulting graphs. Note that the default graph template used by Origin may look just like an excel graph. You will have to customize your graph to match the look that you are looking for, and of course, reuse the template you have created.


Cite as:
Saad, T. "Setting Column Values in Origin – the Programmers Way!". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/02/setting-column-values-in-origin.html

Wednesday, May 14, 2008

Set Column Values in Origin

Most of the times, when importing data into OriginLab, I need to normalize the data by a certain value, or perform certain calculations over each column. When this normalization or calculation is the same for all columns (i.e. normalize the column by 10) it is a hassle to go over each column, right click on it, select "Set Values", and then type in the formula for that column. This is tedious when my columns have long times. There a much easier way of doing this by using the "Before Formula Scripts". I know that this functionality is available as of Origin 8.0. Here's how I am currently doing it:

  1. Select the first column by clicking on its title label
  2. Right click and invoke the "Set Values" dialog box
  3. Click on the little arrow to the bottom right (called "Show Scripts")
  4. In the "Before Formula Scripts" text box, type in the following
    // Get index of current column
    const nn = _ThisColNum;
    // Perform numerical operations on this column
    wcol(nn) /= 10;

  5. Click apply
  6. Select the formula and copy it (Ctrl + c)
  7. Now go to the next column by clicking on the Next Column button (or simply selecting another column)
  8. Paste the formula (Ctrl + v) and click apply
Voila!

I do this for all the columns. This process is very fast if you have a good handle on using the keyboard.

Cite as:
Saad, T. "Set Column Values in Origin". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2008/05/set-column-values-in-origin.html