The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Plotting from different worksheets
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

kais

Spain
Posts

Posted - 01/14/2005 :  08:53:21 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System: Windows XP

Hello everybody. I have been wondering for a long time wether is there any way of plotting two datasets from different worksheets. I usually store similar data related to an specific experiment in the same worksheet. I usually need to plot one variable vs another one, stored in a different worksheet. I have been browsing origin's help and didn´t find a way to do it. I had also had some experience in labtalk scripting and tried to look for it in labtalk or originC help, but couldn´t find any answer. Does anyone know any way to plot different datasets from different worksheets in the same plot, so it might be possible to do linear fittings and so on?. Thanks a lot for the help.

easwar

USA
1965 Posts

Posted - 01/14/2005 :  10:10:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

This is possible with Origin C code such as below, where a curve object is first constructed using datasets from two different worksheets and then is added as a plot to a layer programmatically.

To test this code, first create two worksheets with names data1 and data2 and then fill the first column of each with some numbers (try filling with numbers other than just 1, 2, 3 to make sure you see the correct plot). Then compile and link this code and type the function name in script window and hit Enter.

Easwar
OriginLab


void plot_test()
{
// Declare a curve object with X data coming from 1st col of data1 wksheet
// and Y data from 1st col of data2 wksheet
Curve crv("data1_a", "data2_a");

// Create a new graph page and plot this curve
GraphPage gpg;
gpg.Create();
// Point to layer 1 of this graph
GraphLayer gly = gpg.Layers(0);
// Add the curve as a plot in this layer
gly.AddPlot(crv);
// Rescale the layer
gly.Rescale();
}



P.S. I am using hard coded names here to construct the curve which is not recommended - you could look at other curve constructors. Also, once plotted, as long as you are looking at layer contents, things will work fine. I tried fitting etc to the curve and it worked fine. Plot Setup may have problems in correctly interpreting the relationship between the datasets from two different worksheets.

Go to Top of Page

kais

Spain
Posts

Posted - 01/17/2005 :  09:41:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Easwar,

Thanks a lot for your answer. It is very useful and instructive. I have been suspecting that OriginC would be the only way to do it and had started to learn it. I will try your code to see the wonders of OriginC! ;)

Thank you very much
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 01/17/2005 :  09:59:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
FYI, the same thing can be done in LabTalk...

win -t P; // create plot window
set Data2_A -x Data1_A; // assign data1_A as x values for data2_A
lay -i Data2_A; // add plot to layer (data2_A must be a Y col)

Mike Buess
Origin WebRing Member
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000