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
 Sort dataplots in a group inside a graph layer
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Clairekun

Germany
175 Posts

Posted - 08/26/2020 :  09:09:51 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2018b
Operating System: Windows 10

Hello,

Is there any way to sort dataplots? Sort command only works with workshets, but I would need to sort dataplots which were created in the wrong order.

I have between 2 and 5 dataplots I need to order alphabetically, all of them pertaining to a group. There are other dataplots outside that group which do not need sorting.

The discrepancy between the creation order and desired sorting lies in a number inside the dataset names; i.e. names have numbers like 235, 56, 766, 98... creation order follows the first digit only (235-56-766-98), while desired order would be 26-98-235-766. The numbers are only part of the names, although they share the same prefix.

Is there any solution for this, either changing dataplot sorting order or changing creation order?

Thank you.

YimingChen

1667 Posts

Posted - 08/26/2020 :  11:11:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use a piece of Labtalk Script to control the plotting order. The script reads and sorts the column longnames by value, then plot columns with sorted order.


string bkname$ = %H;
dataset dsln, dslnsorted;

for (i = 2; i <= wks.ncols; i++)
{
	wks.col=i;
	dsln[i-1] = numbervalue(wks.col.lname$);
}

dslnsorted = sort(dsln);

for ( i = 1; i <= dslnsorted.GetSize(); i++)
{
	ln = dslnsorted[i];
	//type $(ln);
	range r1 = [bkname$]1!"$(ln)";
	plotxy iy:=r1 plot:=200 ogl:=1;
}

layer -g;




James
Go to Top of Page

Clairekun

Germany
175 Posts

Posted - 08/26/2020 :  11:50:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The thing is, I'm plotting the same worksheet from different workbooks. I mean, what I should change is the workbook reading order. I could perhaps isolate the numbers within the workbook name in a string, so that I could type a command to sort them using that string, but I don't know how to actually order Origin to read workbooks in that order.
Go to Top of Page

YimingChen

1667 Posts

Posted - 08/27/2020 :  09:58:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can order the value in the name of workbook same way as I showed you to sort columns, then plot books in order, the script within loop can be:

for ( i = 1; i <= dslnsorted.GetSize(); i++)
{
	ln = dslnsorted[i];
	range r1 = ["ID$(i)"]1!2;
	plotxy iy:=r1 plot:=200 ogl:=1;
}

Assuming the book name is like ID235, ID56, etc.

James
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