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
 Line style in Origin
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

tmsthomas

7 Posts

Posted - 12/18/2015 :  10:38:50 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System: 8.6.0

Dear users,

I've just started to use Origin and there's one question regarding plotting style:
How can I manage to show different plots in one graphs with different styles?
F.e. when I'm having 4 Columns, the first one is x, the other 3 are y values. The first y column should be displayed with black symbols, the second one with an thicker than usual line and the third one in red with an standard thickness line.

Please tell me if it is possible to do that? As I'm also using a Labview Labtalk-File to load my data, it would be very helpful for me, if you can tell me, how I do that in Labtalk automatically. The total number of plots within one graph will vary from loaded data file to file - but there is always the 2 plots which should be black - and at least one (up to 5) colored graphs in addition.

I hope you will be able to help me.

Thank you!
Thomas

wks.colSel(2,1); //x value
wks.colSel(wks.nCols,1); //symbols
wks.colSel(wks.nCols-1,1); //thick black line

for (ii=4;ii<=wks.nCols-3;ii++)
{
wks.colSel(ii,1); //colored
}

//plot Selected columns1
//worksheet -p 20;

Edited by - tmsthomas on 12/18/2015 10:41:40 AM

SeanMao

China
288 Posts

Posted - 12/19/2015 :  04:57:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I just wrote some simple code for your three requirements:


plotxy iy:=([Book1]Sheet1!1,[Book1]Sheet1!2) plot:=201; // Plot 2nd column as scatter, default is black
plotxy iy:=([Book1]Sheet1!1,[Book1]Sheet1!3) plot:=200 ogl:=[Graph1]1!; // plot 3rd col as line
layer.plot=2; // activate 2rd plot
set %c -w 1000; // set plot width as 2
plotxy iy:=([Book1]Sheet1!1,[Book1]Sheet1!4) plot:=200 ogl:=[Graph1]1!; // plot 4th col as line
layer.plot=3; // activate 3rd plot
set %c -c 2; // set color as red


You can start from here and add what is missing.

Give it a try and see how it goes!

Regards!

Sean

OriginLab Tech. Service
Go to Top of Page

tmsthomas

7 Posts

Posted - 12/21/2015 :  10:32:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

thank you for your quick response. I just tried to add your code to my script, but I received an error, when I'm trying to load the second set of my data:

[21.12.2015 16:16:53]
WKS.NCOLS: object property not found!

[21.12.2015 16:16:53 plotxy]
Unknown, VarName = iy, VarValue = 

[21.12.2015 16:17:34 plotxy]
Unknown, VarName = iy, VarValue =


Code so far:
plotxy iy:=(2,$(wks.nCols)) plot:=201; //plotxy iy:=(2,4) plot:=201; // Plot 2nd column as scatter, default is black
plotxy iy:=(2,3) plot:=200 ogl:=[Graph1]1!; // plot 3rd col as line//
layer.plot=2; // activate 2rd plot


I'm not fully sure, what is going wrong, but I guess it is the ogs-command, which should assign the plot to the same graph as the one before?
Is there any way to solve that issue?

Thomas
Go to Top of Page

SeanMao

China
288 Posts

Posted - 12/21/2015 :  8:35:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

When you use this notation without specifying the workbook and worksheet, Origin by default will use the data from active workbook:
plotxy iy:=(2,4) plot:=201;

However, when you made a plot you activated a graph window and it denied the access to worksheet data which results in the error message. That is why I always used the full range notation to refer to data:

plotxy iy:=([Book1]Sheet1!1,[Book1]Sheet1!3)

Otherwise, you will need to reactivate the workbook window and run the command every time you need to access worksheet using:

win -a Book1;
plotxy (2,3)
win -a Book1;
pltxy (4,5)
..

Regards!

Sean
Go to Top of Page

tmsthomas

7 Posts

Posted - 01/02/2016 :  05:32:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

thank you again for your explanation. But there are two more things I cannot understand at the moment:

1.) No matter what code I'm using, I cannot change line width and line color with the code:
win -a Book1;
plotxy (2,8) plot:=201;
win -a Book1;
plotxy (2,4) plot:=200 ogl:=[Graph1]1!;
layer.plot=2; 
set %c -c 2; // set color as red

There are no changes in the Graphs. Do you have any suggestions what could go wrong there?
I already disabled my theme, but this doesn't make any difference.
//themeApply2g theme:= "testtheme";





2.) The second questions is just a question of interest: When I'm trying to do it like you have shown in your code I need to specify the sheet, where the data are in. As the data is imported from a csv-file via impasc
impasc Options.Names.FNameToBk:=0 Options.FileStruct.NumericSeparator:=0;

, the sheets name is the same as the data file (what I don't want to change). But then I need to know the name of this file and how to use it in the plotxy command.
When I do it manually, your code works fine:
plotxy iy:=(test!2,test!8) plot:=201; // Plot 2nd column as scatter, default is black
plotxy iy:=([Book1]test!2,[Book1]test!7) plot:=200 ogl:=[Graph1]1!; // plot 3rd col as line
layer.plot=2; // activate 2rd plot
set %c -w 1000; // set plot width as 2

Is there any way to find out the sheets name?
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 01/03/2016 :  7:46:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
When you have code like

plotxy (2,4) plot:=200 ogl:=[Graph1]1!;
layer.plot=2; 
set %c -c 2; // set color as red


The active window may not be Graph1, so subsequent commands will not be applied to it, try changing it as follows:

plotxy (2,4) plot:=200 ogl:=[Graph1]1!;
win -o graph1 {layer.plot=2; set %c -c 2};


You can look up the win -o command switch here:

http://www.originlab.com/doc/LabTalk/ref/Window-cmd#-o.3B_Execute_the_specified_script_for_the_named_window

or read more herehttp://www.originlab.com/doc/LabTalk/guide/Running-Scripts


CP

Go to Top of Page

SeanMao

China
288 Posts

Posted - 01/05/2016 :  01:38:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Your first question is already answered by cpyang. When you execute the following line:
plotxy (2,4) plot:=200 ogl:=[Graph1]1!;

It does not activate graph1 instead, so you need to add one more line before you can continue to run other commands:
win -a Graph1;

For your second question, with workbook active:

string wksname$ = wks.name$;

plotxy iy:=(%(wksname$)!1,%(wksname$)!2) plot:=201;

Regards!

Sean



quote:
Originally posted by tmsthomas

Hi,

thank you again for your explanation. But there are two more things I cannot understand at the moment:

1.) No matter what code I'm using, I cannot change line width and line color with the code:
win -a Book1;
plotxy (2,8) plot:=201;
win -a Book1;
plotxy (2,4) plot:=200 ogl:=[Graph1]1!;
layer.plot=2; 
set %c -c 2; // set color as red

There are no changes in the Graphs. Do you have any suggestions what could go wrong there?
I already disabled my theme, but this doesn't make any difference.
//themeApply2g theme:= "testtheme";





2.) The second questions is just a question of interest: When I'm trying to do it like you have shown in your code I need to specify the sheet, where the data are in. As the data is imported from a csv-file via impasc
impasc Options.Names.FNameToBk:=0 Options.FileStruct.NumericSeparator:=0;

, the sheets name is the same as the data file (what I don't want to change). But then I need to know the name of this file and how to use it in the plotxy command.
When I do it manually, your code works fine:
plotxy iy:=(test!2,test!8) plot:=201; // Plot 2nd column as scatter, default is black
plotxy iy:=([Book1]test!2,[Book1]test!7) plot:=200 ogl:=[Graph1]1!; // plot 3rd col as line
layer.plot=2; // activate 2rd plot
set %c -w 1000; // set plot width as 2

Is there any way to find out the sheets name?

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