Author |
Topic |
|
Masterchief1
Portugal
5 Posts |
Posted - 06/06/2018 : 12:10:43 PM
|
Origin Ver. and Service Release (Select Help-->About Origin): 9.5.1.195 Operating System: W10
I have several workbooks with 5 sheets each. I want to create graphs of the first sheet of all books, the second sheet of all books, etc. But when i'm creating the graph in the plot setup, when i sort by the sheet name (the 5 sheets in all books have the same name between the books) the order of the books is random. I wanted to have in all the graphs the same color for the same worbooks but because the workbook order is random i cannot do this the easy way. Any solution?
|
|
Hideo Fujii
USA
1582 Posts |
Posted - 06/06/2018 : 4:50:25 PM
|
Hi Masterchief1,
How about to run the following x-function command (from a Command or Script window) to merge all books with included sheets?:merge_book single:=0; This creates a single workbook (thus no worried about which book is the source), and the same conflicted sheet names are distinguished by the enumeration (which can tell from which book the sheet came). Then, you can plot from this merged book.
I didn't want to propose a script approach because it might be a quite ad hoc code. I hope this helps your work.
--Hideo Fujii OriginLab |
|
|
Masterchief1
Portugal
5 Posts |
Posted - 06/07/2018 : 06:23:11 AM
|
Thank for your answer!
If i merge all in one book i can't order by sheets because of the diferent name, and even if i could the same problem would persist most probably.
To explain better i will give an example:
1 - I have 10 books (Book1, Book2, etc). 2 - Each book has 5 sheets (Sheet1, Sheet2, etc) 3 - Now i want a graph of all the Sheet's1 from all books, and all the Sheet's2, etc.
But when i go to the "Plot Setup: Select Data ..." window, when i sort by sheet name, the order of the books in each sheet group is random:
Book1|Sheet1 Book2|Sheet1 Book3|Sheet1 Book4|Sheet1 etc | etc Book3|Sheet2 Book2|Sheet2 Book1|Sheet2 Book4|Sheet2 etc | etc
etc
So when i plot the graph from Sheet's1 i get a color for each book, but when i plot for the sheet's2 the same workbook has a diferent color :(
Any way to solve this?
|
Edited by - Masterchief1 on 06/07/2018 06:25:25 AM |
|
|
Hideo Fujii
USA
1582 Posts |
Posted - 06/07/2018 : 11:13:44 AM
|
Hi Masterchief1,
In the Plot Setup dialog, you can change the plot order by click-and-drag the plot entry as shown below.
Does this work for you?
--Hideo Fujii OriginLab |
|
|
Masterchief1
Portugal
5 Posts |
Posted - 06/07/2018 : 4:04:37 PM
|
As always thank you for your reply.
Of course it works, but why doesn't the order of books match all the different stacks of sheets??? It makes no sense to me? Even when we order by alphabetical order in the books column the sheets are not ordered by their order in their respective workbooks. Why?
And now i only have 11 workbooks, it is still doable, but next month i will start to have 100 each time. I can't do that every time for every stack of sheets :/
Is there another solution? |
Edited by - Masterchief1 on 06/07/2018 4:05:17 PM |
|
|
Hideo Fujii
USA
1582 Posts |
Posted - 06/07/2018 : 6:34:21 PM
|
Hi Masterchief1,
Could you try the following script, which picks up e.g. Sheet2 in all books, and plots from their X=col(1), Y=col(2):window -t plot; //make a new graph
gr$=%H; //output graph name
doc -e W { //repeat over books
plotxy iy:=[%H]Sheet2!(1,2) plot:=202 o:=[%(gr$)]1!; //plot Line+Symbol all Sheet2 as Y=col(2)
}
layer -g; //group datasets Hope this works.
--Hideo Fujii OriginLab |
|
|
Masterchief1
Portugal
5 Posts |
Posted - 06/08/2018 : 04:42:34 AM
|
Failed to resolve range string, VarName = iy, VarValue = [A10laser]Sheet2!(1,2) #Command Error!
The script send this error.
EDIT: So i tested a bit with the script and i think the problem is with the sheet name. My sheets are not called Sheet1, Sheet2, etc. Is there a "default name" that is independent of the sheet's short name in order to put in the script?
EDIT2: I just thought that could be exactly Sheet1, Sheet2, etc, but if it is, it doesn't work for me :/
EDIT3: I think i found it!I have to put it like this right? "plotxy iy:=[%H]2!(1,2) plot:=202 o:=[%(gr$)]1!;"
|
Edited by - Masterchief1 on 06/08/2018 05:20:36 AM |
|
|
Masterchief1
Portugal
5 Posts |
Posted - 06/08/2018 : 05:22:27 AM
|
Thank you very much for your help so far, i only have 2 last questions now:
1: o:=[%(gr$)]1! -> what does this mean?
2: how do make the graph created by the script use a user template created by me? |
|
|
Hideo Fujii
USA
1582 Posts |
Posted - 06/11/2018 : 12:03:51 PM
|
Hi Masterchief1,
> 1: o:=[%(gr$)]1! -> what does this mean?
The notation follows the way to specify the range: https://www.originlab.com/doc/LabTalk/guide/Range-Notation
Here, $gr is a string variable to hold the active graph window name (came from the system register %H, created and activated by the previous window -t command). %(...) is to "evaluate" the variable a step further. But this x-function may work without %(...). "1" is a shorthand notation of the "1st" layer.
> 2: how do make the graph created by the script use a user template created by me?
You can specify the template file name (in the User Files Folder) in the first line to create an empty graph window like: window -t plot myTemplate.otpu; //make a new graph using the template Hope these make sense.
--Hideo Fujii OriginLab |
|
|
|
Topic |
|