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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 plotting multiple graphs from multiple columns

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
alpy Posted - 11/19/2014 : 4:01:16 PM
Origin Ver. and Service Release (Select Help-->About Origin): 7.5
Operating System: win2000

hello everyone, I am quite new to the forum and also to the writing a script. I need to plot multiple x-y line graphs from different columns. Lets say I have 4 columns and I want to plot column 1 as x, 2 as y for the first graph, and 3 as x, 4 as y for the second graph.
For instance:
plotxy iy:=(1,2) plot:=200;
and
plotxy iy:=(3,4) plot:=200;
at the same time. But how do I get these two commands working together ? When I write them both, it plots the first graph, and than says Command Error! not plotting the second one.

When I use plotxy iy:=((1,2),(3,4)) plot:=200; It plots everything on the same graph. But I need separate graphs.

(1,2) and (3,4) are only example btw. There are more columns on the original problem, but I think I can manage it after I can find out how to plot these two on different graphs.

Thanks in advance!!



8   L A T E S T    R E P L I E S    (Newest First)
yuki_wu Posted - 11/17/2017 : 02:34:57 AM
Hi,

Add two variables in the example above:
string PlotIndex$ = "(1,2)|(3,4)";
string DataBook$ = %H; // Remember the data workbook's name
string GraphName$ = "Test1|Test2";
string GraphTemplate$ = "Polar|glWater3D";
for (ii = 1; ii <= PlotIndex.GetNumTokens("|"); ii++) 
{
	window -a %(DataBook$);
	string CurrentPlot$ = PlotIndex.GetToken(ii,"|")$;
	string CurrentName$ = GraphName.GetToken(ii,"|")$;
	string CurrentTemplate$ = GraphTemplate.GetToken(ii,"|")$;
	plotxy iy:=%(CurrentPlot$) ogl:=[<new template:=%(CurrentTemplate$) name:=%(CurrentName$)>]; 
}

More info about plotxy X-Function please refer to:
https://www.originlab.com/doc/X-Function/ref/plotxy

Regards,
Yuki
OriginLab
spn Posted - 11/16/2017 : 04:38:48 AM
Hey,

I had the very same problem and this conversation has really helped.
Thank you all very much.

But, is there a way to give different names for each graph and apply themes separately to each of them?

Could anyone please help me with the same?

spn
alpy Posted - 11/21/2014 : 6:08:28 PM
Works like a charm! Thank you very very much!!


quote:
Originally posted by lkb0221

Hi, Alpy

So just activate the workbook you want to operate on, and run the following script:

// Start
string PlotIndex$ = "(1,6)|(2,4)|(6,7)|(8,7)";
string DataBook$ = %H; // Remember the data workbook's name
for (ii = 1; ii <= PlotIndex.GetNumTokens("|"); ii++) {
window -a %(DataBook$);
string CurrentPlot$ = PlotIndex.GetToken(ii,"|")$;
plotxy iy:=%(CurrentPlot$);
}
// End


If you want to change the column for plotting, simply modify the PlotIndex$ variable.

Zheng
OriginLab

lkb0221 Posted - 11/21/2014 : 3:25:54 PM
Hi, Alpy

So just activate the workbook you want to operate on, and run the following script:

// Start
string PlotIndex$ = "(1,6)|(2,4)|(6,7)|(8,7)";
string DataBook$ = %H; // Remember the data workbook's name
for (ii = 1; ii <= PlotIndex.GetNumTokens("|"); ii++) {
window -a %(DataBook$);
string CurrentPlot$ = PlotIndex.GetToken(ii,"|")$;
plotxy iy:=%(CurrentPlot$);
}
// End


If you want to change the column for plotting, simply modify the PlotIndex$ variable.

Zheng
OriginLab
alpy Posted - 11/21/2014 : 09:19:58 AM
Hello, thanks again for the answer. I tried this way but is worked only for the first graph, when I tried to execute it second time, it said command error! unless I delete the first graph. So back to the point, I need 4 Graphs, to be specific from the columns (1,6) , (2,4) , (6,7) , (8,7) for every single file and I don't want to select plot, then select every time the right columns from that table, I just want to write a command, and voila, there are the 4 graphs each time I need. But I can't execute the script for multiple graphs in one script, or without deleting the graphs, right ?



quote:
Originally posted by jasonzhao

Hello,

you can try to make a macro


define plot{             //define macro first

win -a Book1; // active the data book;

getn
(X) x 
(Y) y;   // use dialog for input

plotxy iy:=($(x),$(y));    // plot XY

};


//------------------------------------//

plot  //Executing the macro each time for one plot



Best regards,
Jason Zhao
OriginLab Tech Service




jasonzhao Posted - 11/20/2014 : 10:58:50 PM
Hello,

you can try to make a macro


define plot{             //define macro first

win -a Book1; // active the data book;

getn
(X) x 
(Y) y;   // use dialog for input

plotxy iy:=($(x),$(y));    // plot XY

};


//------------------------------------//

plot  //Executing the macro each time for one plot



Best regards,
Jason Zhao
OriginLab Tech Service


alpy Posted - 11/20/2014 : 05:54:31 AM
Hello, thanks for the reply. But what happens when the problem gets complicated? For example when I need to plot (2,5),(1,3),(6,4) and so on (without a pattern like (i,i+1) ).. Is there a way to define the columns only by entering the column number ?


quote:
Originally posted by jasonzhao

Hello,

you can use for statement to plot multiple graphs.

for(int i=1;i<5;i=i+2)
{
win -a Book1; // active the data book

plotxy iy:=($(i),$(i+1)) plot:=200; // plot the XY data

}

Best regards,
Jason Zhao
OriginLab Tech Service

jasonzhao Posted - 11/19/2014 : 10:13:06 PM
Hello,

you can use for statement to plot multiple graphs.

for(int i=1;i<5;i=i+2)
{
win -a Book1; // active the data book

plotxy iy:=($(i),$(i+1)) plot:=200; // plot the XY data

}

Best regards,
Jason Zhao
OriginLab Tech Service

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000