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 for Programming
 Forum for Origin C
 Plot Part of Worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jguenrdc

USA
Posts

Posted - 04/13/2006 :  5:48:09 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): OriginPro 7.5 SR6
Operating System: XP

I'm sure this can be done easily, but I can't find the right combination of things in the Origin C docs.

I would like to create a plot based on a subset of rows (for example 379 through 1638) and 2 nonconsecutive columns (for example L=X data and E=Y data) of a worksheet. I would prefer to do this without creating a new worksheet first.

Can any one give me some hints? Thanks.

Jay

easwar

USA
1965 Posts

Posted - 04/13/2006 :  8:43:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jay,

Here is one way to do this:

Easwar
OriginLab




void plot_range()
{
// Point to active worksheet
Worksheet wks = Project.ActiveLayer();
if( !wks ) return;

// Create curve object that attaches to Col(L) as Y, and Col(E) as X
string strWksName = wks.GetPage().GetName();
Curve crv(strWksName + "_L", strWksName + "_E");
// Or use constructor with index number
// Curve crv(wks, 11, 4);
// Note that there are many curve constructors, some of which that
// directly attach to the data, and some that attach to a copy
// In your case you want to attach to the data directly
if( !crv ) return;

// Create a graph page and add curve to layer
GraphPage gpg;
// Use default Orign.otp or one of your custom templates
gpg.Create("Origin");
// Point to active layer and add curve
GraphLayer gly = gpg.Layers(-1);
if(! gly ) return;
gly.AddPlot(crv);

// Get the active data plot object in layer and set range
DataPlot dp = gly.DataPlots(-1);
if( !dp ) return;
dp.SetRange(100, 200);

// Rescale layer
gly.Rescale();
}




Go to Top of Page

jguenrdc

USA
Posts

Posted - 04/14/2006 :  12:02:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Easwar,

Thanks for the help, it was switching to the DataPlot and setting the range that I was missing.

I have an additional question now. I want to show several of these sections of data on one graph. Do I copy the layer, then point to the DataPlot and change the range? Or is there a way to use one set of data to show all the plots?

Jay
Go to Top of Page

easwar

USA
1965 Posts

Posted - 04/14/2006 :  12:21:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

I want to show several of these sections of data on one graph. Do I copy the layer, then point to the DataPlot and change the range? Or is there a way to use one set of data to show all the plots?
Jay



Hi Jay,

Do you mean you want to plot differet ranges of the same data/curve in a graph? If that is the case, currently plotting the same data more than once in one layer is not supported. So you will need to one of the following:
a> create a second worsheet and extract each range from original data and add x,y columns in this second worksheet and then plot them all into one graph layer
Or
b> create a graph with multiple layers and plot each range in a separate layer

Easwar
OriginLab

Go to Top of Page

jguenrdc

USA
Posts

Posted - 04/14/2006 :  1:03:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hmm, now I can't figure out how to add a graph layer to an existing graph page in Origin C. I thought there would be a Create method for GraphLayer objects or an AddLayer method for GraphPage objects, but I don't see anything like that.

Jay
Go to Top of Page

easwar

USA
1965 Posts

Posted - 04/14/2006 :  1:20:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jay,

So looks like you don't want to create a new wks, but use the multiple layer approach instead.

You can add layer to graph by calling back to LabTalk script from Origin C, with code such as below.

If you take this approach, you may need to programmatically further manipulate the layers to perhaps position them, turn on-off labels, ticks etc.

I then suggest the following alternative, if feasible:
-> Determine how many layers you want ahead of time
-> Manually create a graph with the needed layers, arranging them and modifyng them as you desire
-> Save that graph as a template and then create an instance of that template in your code using the gpg.Create() method
-> Then access the various layers in the graph, which will already be there, and plot into them.
Doing this could reduce the amount of coding you need to do to arrange the layers etc.

Easwar
OriginLab



GraphPage gpg;
gpg.Create("Origin");
GraphLayer gly1 = gpg.Layers(0);
LT_execute("layer -n;");
GraphLayer gly2 = gpg.Layers(1);





Edited by - easwar on 04/14/2006 1:22:00 PM
Go to Top of Page

jguenrdc

USA
Posts

Posted - 04/14/2006 :  3:16:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Easwar,

Thanks for the help.

Jay
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