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
 LabTalk Forum
 setting symbol shape in for loop
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

JokerOne

Germany
58 Posts

Posted - 02/25/2016 :  05:48:27 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 9.1 and Service Release 1(Select Help-->About Origin):
Operating System: Win7

Hello everybody,

once again I am that LabTalk-desperate, that I request your help:

In the following code, I cannot manage to set the symbol shape to "circle" for all of the data plots generated in the loop, only at the first plot, the changes are visible.

In my struggling I tried both of the for loops below. Both show the same result.

Any help is appreciated.

First try:

for (ii=1;ii<= 3; ii++)
{
x_point_plot = {1};
y_point_plot = {1};
plotxy iy:=(x_point_plot,y_point_plot) plot:=201 ogl:=[MyGraph]1! color:=(ii+1);

layer -c; // the resulting number is set in the internal variable "count"
type $(count);
range rr = [MyGraph]Layer1!$(count); // Create the according range
set rr -k 2; // Set marker type
}

Second try:

for (ii=1;ii<= 3; ii++)
{
x_point_plot = {1};
y_point_plot = {1};
plotxy iy:=(x_point_plot,y_point_plot) plot:=201 ogl:=[MyGraph2]1! color:=(ii+1);
set %C -k 2; // Set marker type
}

cpyang

USA
1406 Posts

Posted - 02/25/2016 :  08:51:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Can you use real data? To make a graph, data must be somewhere outside the graph, as the graph simply plot the actual data. I tried this and it worked fine

int npts = 3;
range ss = [book1]1!;
ss.ncols=2 * npts; // XY

for (int ii=1, jj=1;ii<= 3; ii++,jj++)
{
	range xx = [book1]1!$(jj);jj++;
	range yy = [book1]1!$(jj);
	xx = {1,2};
	yy = {$(ii),$(jj)};
	plotxy iy:=(xx,yy) plot:=201 ogl:=[MyGraph]1! color:=(ii+1); 

	layer -c; // the resulting number is set in the internal variable "count"
	type $(count);
	range rr = [MyGraph]Layer1!$(count); // Create the according range
	set rr -k 2; // Set marker type
} 

Go to Top of Page

JokerOne

Germany
58 Posts

Posted - 02/25/2016 :  09:06:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the answer.

Sorry, I might have stated this not too clear:
The plot itself works, the data are plot, but the symbol shape is not changed to "circle" (option - k 2).

This still holds true for the code you proposed, unfortunately.

Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 02/25/2016 :  2:56:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi JokerOne、

Your sample code has plotted the same dataset repeatedly as shown below:



So, no matter referred by %C or the dataset name, it always points the first plot. (The same dataset name cannot
make the plots distinguishable each other.) To solve the problem, you have to create separate datasets like:
for (ii=1;ii<= 3; ii++) {
  x_point_plot$(ii) = {1,2,3};
  y_point_plot$(ii) = {10,20,30};
  plotxy iy:=(x_point_plot$(ii),y_point_plot$(ii)) plot:=201 ogl:=[MyGraph2]1! color:=(ii+1);
  set y_point_plot$(ii) -k 2; // Set marker type
} 

As cpyang has suggested, if you used the real data, you wouldn't have encountered such confusing situation.

Hope this makes sense.

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 02/25/2016 3:01:29 PM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 02/25/2016 :  9:51:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I don't have Origin9.1, I checked in 2015 and my original code worked fine with symbols set to circle.

If you don't want to use book, just want graph with loose data, you will still need to have different data for each plot, try the following:


//run with clean new session of Origin
[Main]
win -t plot origin mygraph;
for (ii=1;ii<= 3; ii++)
{
	x_point_plot$(ii) = {1,2};
	y_point_plot$(ii) = {$(ii),$(ii)+1};
plotxy iy:=(x_point_plot$(ii),y_point_plot$(ii)) plot:=201 ogl:=[MyGraph]1! color:=(ii+1); 

	layer -c; // the resulting number is set in the internal variable "count"
	type $(count);
	range rr = [MyGraph]Layer1!$(count); // Create the according range
	set rr -k 2; // Set marker type
} 

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