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
 Plotting to different layers
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

billaravi

USA
14 Posts

Posted - 08/09/2005 :  4:29:30 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (7.5):
Operating System:XPPRO

Hi,
I have XY data in a worksheet and the number of these XY datasets ranges between 3 and 6. I need to plot each XY data set to a different layer on the same graph page. Also is it possible in the graph page to hide all the other layers and show only one layer by clicking on the layer button on the graph page.
thanks

easwar

USA
1965 Posts

Posted - 08/09/2005 :  4:51:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

To hide/show layers, one can right-click on the layer icon and toggle the status of the "Hide Layer" context menu.

As for plotting the data, are you asking how to create a graph from scratch where you keep adding layers to the page for each dataset? Or would you start from a template that has many layers and just programmatically plot each dataset into one of the existing layers?
The code would be different for each situation.

For plotting data into existing layer, you can find information on that in the programming help files. There are methods such as AddPlot in GraphLayer class.

For creating new layers in a graph, this is not available in OC in 7.5, and so if you are looking to create layers programmatically, you will need to use LabTalk from inside Origin C to add the layer and then you can arrange/resize the added layer etc using Origin C.

Easwar
OriginLab

Go to Top of Page

billaravi

USA
14 Posts

Posted - 08/09/2005 :  8:03:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Easwer,
I want to create the layers programatically and then add the plots to the layers. As you said that its not possible using origin C. Could you hint me how to achieve this by embedding labtalk in origin C.

many thanks
ravi
Go to Top of Page

easwar

USA
1965 Posts

Posted - 08/10/2005 :  10:24:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Ravi,

You can use code such as posted below. Note that there is no simple command at this point to programmatically rearrange all layers in a specific configuration such as say 2x3 although that can be done from the GUI manually using the layer tool. So for now you would need to get and set the layer properties such as width, height, x, y offset etc.

Another suggestion I have is that you could instead do the following:
1> create a custom template with max number of layers that you would want to use
2> create a new graph page using this custom template
3> add data plots to as many layers as applicable depending on the number of datasets you have
4> delete all empty layers
This may work a bit better than having to create and arrange layers perhaps.

Easwar
OriginLab


void add_layer()
{
// Create a new graph page using existing template
GraphPage gpg;
// Use Origin.otp which has one layer, or any custom template
gpg.Create("Origin");
// Use LT layer command to add another layer to the graph page
// Layer command has many options such as linking new layer to
// existing active layer etc - see LT language reference help file
LT_execute("layer -n;");
// Get the index of the layer just added - should be the active layer
int nLyIndex = page_active_layer_index(gpg);
// Declare OC layer object using this index
GraphLayer gly = gpg.Layers(nLyIndex);
// Do manipulations to this added layer such as resizing it
// Set dimension in inches
gly.Dimension.Units.nVal = 1;
// Set top, left, width, height
gly.Dimension.Top.dVal = 1;
gly.Dimension.Left.dVal = 5;
gly.Dimension.Width.dVal = 5;
gly.Dimension.Height.dVal = 3;
}



Go to Top of Page

greg

USA
1379 Posts

Posted - 08/10/2005 :  10:36:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
With regard to viewing layers...

There is also an option on the View : Show menu called "All Layers" which is checked by default. If you uncheck this option, then only the active layer will display and you can change the active layer by clicking the layer icon in the upper left. This is in addition to the Hide/Show option Easwar mentioned.

Go to Top of Page

billaravi

USA
14 Posts

Posted - 08/11/2005 :  12:29:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Easwer,
I liked your second suggestion and tried it, but only suceeded partially. I created a graph template with 6 layers and in my program, I added plots to the first 3 layers. Its fine so far. But the problem was to delete the remaining 3 empty layers.

When I tried the following code it workded perfectly

LT_execute("layer -s 6;");
LT_execute("layer -d ;");
LT_execute("layer -s 5;");
LT_execute("layer -d ;");
LT_execute("layer -s 4;");
LT_execute("layer -d ;");


I wanted to generalize it, so I put it in a loop, but its not doing it now. Its deleting the wrong layers.
 
int k;
for ( k = 6; k >= 4; k = k-1 )
{
LT_execute("layer -s k ;");
LT_execute("layer -d ;");
};


Am I doing an obvious blunder? or is there a more elegant way to delete the empty layers.
Thanks
Ravi
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 08/11/2005 :  12:35:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Ravi,

LabTalk doesn't know about Origin C variables. Try this...

int k;
for ( k = 6; k >= 4; k = k-1 )
{
LT_execute("layer -s " + k);
LT_execute("layer -d ;");
};

Mike Buess
Origin WebRing Member
Go to Top of Page

easwar

USA
1965 Posts

Posted - 08/11/2005 :  12:51:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

or is there a more elegant way to delete the empty layers.




Hi Ravi,

You can use code such as this example which deletes layer 2:


GraphPage gpg = Project.Pages();
GraphLayer gly = gpg.Layers(1);
gly.Destroy();
gpg.Refresh();



Easwar
OriginLab

Go to Top of Page

billaravi

USA
14 Posts

Posted - 08/11/2005 :  1:18:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanx folks...that works perfect.
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