T O P I C R E V I E W |
Clairekun |
Posted - 05/20/2014 : 6:43:58 PM Origin Ver. and Service Release (Select Help-->About Origin): 9 Operating System: windows 7
I am required to show my XY fitted plot along with results summary. I have an XYXY book where I need to plot both XY ranges in the same layer - I have already done this using labtalk. And then, I need to perform two linear fits, one per XY set of data, having a summary table of results embedded in it.
This:
This must be done with doc -ef W because I have several workbooks that need to go through the same process.
I am trying to define strings before specifying fitting ranges (string strBook$ = page.name$ and string strSheet$ = layer.name$), but I don't know much about programming and I am totally lost. I have only seen this for one column, while I need two and two different ranges.
Thank you in advance.
|
22 L A T E S T R E P L I E S (Newest First) |
Echo_Chu |
Posted - 06/05/2014 : 06:16:50 AM If what you want is result table on graph, then you can 1. Double click to open the table on graph in a worksheet
2. Customize the opened table 3. Right click on the title bar of Table1 and select Save Template As. Save the template as MyFitLinear.
4. Specified the saved template in the script
//Specify the customized tempate.
lrgui.GUI.Output.PlotSettings.PasteResultTable.TableTemplate$= "MyFitLinear.otw";
I am afraid that there is no way to change the style of table on report sheet yet. Could you let me know why you want to change it perhaps we can see whether there is workaround for it
|
Clairekun |
Posted - 06/05/2014 : 06:11:16 AM It is actually both:
- Change summary table in report sheet - Modified Summary table as result table in graph
|
Echo_Chu |
Posted - 06/05/2014 : 06:03:26 AM I assumed you want to change the summary table as result table on graph as below
But from the image of your last reply it looks you want to change the summary table on report sheet.
|
Clairekun |
Posted - 06/05/2014 : 05:19:21 AM Sorry for the misunderstanding, the code for not updating the legend worked perfectly :) Thanks.
The template is saved in otp format. I read the wiki on themes and templates thoroughly and reached to the conclusion that styles could only be saved in themes, since I also checked that, while table structure was correct once I applied the template, colors weren't changed.
Initial summary table style:
Final summary table style:
What I did:
- Change colors - Change cell alignment - Merge certain cells - Change worksheet format to allow rich text |
Echo_Chu |
Posted - 06/05/2014 : 04:17:06 AM
lrgui.GUI.Graph1.UpdateLegend = 0;
I am sorry that the treenode called Graph1 but in fact it is equivalent to the setting in dialog.
So please insert this line before the line to execute xop and try again.
// perform linear fit and generate a report with the prepared GUI tree
xop execute:=report iotrgui:=lrGUI;
Could you let me know what format you are trying to save in the template? I assume all format for style should be saved in template of table.
theme may not work well for the table embedded in the graph. I still suggest you use template for your requirement.
It would help if you can show me an image how you want to change to summary table on graph to be so that we can find the best solution for your requirements. |
Clairekun |
Posted - 06/04/2014 : 04:25:55 AM As for legend not updating, I was trying to say that the fact that Graph1 is inside that line of code makes it only work for graphs called Graph1 (as far as I understand), not for all graphs. This is why I was thinking of modifying all legends with a doc -ef P {} script after fitting.
I did save the template correctly, although I believed it would save format information when it actually doesn't. This is my mistake and is the reason why I didn't get the desired results.
Since myFitLR.ini is already a theme, I assume I can't set a format theme to the results table, right? Or is there a way to apply 2 themes, one after another? (first ini for Summary table and then oth for colors and styles).
I assume it would have to be done after report tables are created. Since report tables are worksheets, applying oth themes for multiple report tables at once would result in applying them to data worksheets, too. The only thing I can think of would be renaming report tables when creating them (someting like FitLR bookname, for example, to identify them more easily) and, then, applying the theme to those worksheets starting with FitLR using themeapply2g. Is this possible? It would certainly make things much easier.
I do not how to specify that name using themeapply2g (using option:=specified and graph:=something, I would say), so I would need help here. |
Echo_Chu |
Posted - 06/03/2014 : 07:07:29 AM Hi, Claire
I am wondering whether we are talking the same thing.
The report table I am talking about is the report table on graph as image below.
If we are talking with the same thing.
Are you sure you created the template for report table on graph as the steps on the Example on the page?
http://www.originlab.com/doc/Origin-Help/FitRef-CustomReportTable
If yes, could you let me know why you think it seems not work? It would also help if you can send us your project file and show us the effect you want to have.
In regard to the theme, please note that the report table theme is not a oth file. It is a ini file which is to customize the report table on graph.
You can look at the details on the page below. http://www.originlab.com/doc/Origin-Help/FitRef-CustomReportTable#Graph_Table_Theme
As to Can I set the fitting not to update the legend?, I notice you are working with Origin 9.0. Then the setting works for you
lrgui.GUI.Graph1.UpdateLegend = 0;
|
Clairekun |
Posted - 06/03/2014 : 04:31:13 AM Now both lines can be seen and the fitting works nicely, thank you :).
I created a new template for Summary table, but it seems not to work. I tried saving it both as built-in and as user defined, defining and not defining the path, but nothing works. I obtained the same result if fitting manually and defining the template.
Afterwards, I saved table theme (oth file).
- Defining both ini and oth themes resulted in no result table shown and a blank table created.
- If only oth theme is defined, both including and not including the path and extension, same result than above is obtained.
- Same result if fitting manually and defining the theme.
- If I first run the script without the oth theme and then apply this theme, it is shown correctly.
I am totally lost.
As for the legend not updating, since that code was only for graph1 and I will need to do it for all my fitted graphs, odds are I will have to modify them manually or create a script for all plots in folder later. |
Echo_Chu |
Posted - 06/03/2014 : 02:57:31 AM I resent the email with attachment. Please check.
To set specific theme or template to the result table, please look see the page below for instruction of defining theme or template.
http://www.originlab.com/doc/Origin-Help/FitRef-CustomReportTable
You can use script as below to use the cutom theme or template in your codes.
//Specify the customized tempate.
lrgui.GUI.Output.PlotSettings.PasteResultTable.TableTemplate$= "MyFitLinear.otw";
//Specify the customized theme
lrgui.GUI.Output.PlotSettings.PasteResultTable.ThemeRsltTable$="myFitLR.INI";
To set fitting not to update the legend, please use the code
lrgui.GUI.Graph1.UpdateLegend = 0;
But I am sorry that this option was broken since Origin 9.1 SR0. We have reported in our bug tracking database, ORG-10403. Before we got it fixed, perhaps you can manually update the legend with script after fit.
|
Clairekun |
Posted - 06/02/2014 : 08:39:21 AM Thanks so much, Echo.
I couldn't find an attachment in your email, so I tried the code without the new x-function. It works perfectly and Summary shows right where I wanted it to be.
Could you please resend it? Thank you.
Only two more questions that popped into my mind (xop X-function does not show any of these options):
- Is there a way to set an specfic theme or template to the results table? - Can I set the fitting not to update the legend?
Thanks again. |
sjzrifdsa |
Posted - 06/01/2014 : 06:59:45 AM thank you. I have met the same problem recently.
<font color="blue">hi,all!</font id="blue"> |
Echo_Chu |
Posted - 05/30/2014 : 03:56:40 AM You are correct. Sorry that I gave wrong explanation for assigning Y only.
To customize the report table on graph to be the summary, you should
1. Open the file <exe>\CustomTable\FitLinear.INI by notepad 2. Clean all contents in it and copy/paste script below there
[DataLinks]
Entry1=Summary!
3. Save the file as myFitLR.INI in the same folder.
Then use the scirpt below to specify the customized result table theme in linear fit operation
//customize the result table
lrgui.GUI.Output.PlotSettings.PasteResultTable.ThemeRsltTable$="myFitLR.INI";
In regard to only one fitting line can be seen, I am sorry that this is a bug of xop, which I reported in our bug tracking database, ORG-11266. There is a workaround to have all fitting lines on graph but it needs a customized x-function. I will send you the x-function by email. Then you can
1. Drag and drop the x-function,setplotuid.oxf, in Origin 2. Perform linear fit with the codes below
// GUI tree for linear fit
tree lrGUI;
// initialize the GUI tree, with the FitLinear clas
xop execute:=init classname:=FitLinear iotrgui:=lrGUI;
//Specify all data plots on graph to be input data in the GUI tree
ii = 1;
doc -e d
{
%A = xof(%C);
lrGUI.GUI.InputData.Range$(ii).X$ = %A;
lrGUI.GUI.InputData.Range$(ii).Y$ = %C;
setplotuid lrGUI ii; //set plot id to lrgui. please comment this line if you don't have setplotuid.oxf
ii = ii + 1;
}
//customize the result table
lrgui.GUI.Output.PlotSettings.PasteResultTable.ThemeRsltTable$="myFitLR.INI";
// perform linear fit and generate a report with the prepared GUI tree
xop execute:=report iotrgui:=lrGUI;
// clean up linear fit operation objects after fitting
xop execute:=cleanup;
|
Clairekun |
Posted - 05/29/2014 : 05:41:31 AM Thank you. I tried both of them, and this is what I got:
First, I did the fitting manually so that I could compare results.
Second, I used the code with only Y;, the results didn't match.
Third, I specified X, they matched perfectly for both sets of data.
Could it be that, if X is not defined, X values would automatically be set from 1 to n? I can't think of any other reason. I can send you the file in case you want to take a look.
I also noticed that, even though both sets are fitted, only one fitting line can be seen. Would there be a way to see both, following the theme the graph uses?
Aside from that, I would like to know if the report table could be the table "Summary" in the LinearFit report sheet. This contains all the information I require, while the default report table has some extra cells I don't need. |
Echo_Chu |
Posted - 05/29/2014 : 05:16:06 AM X will be automatically assigned as your plot on graph is XY pair.
But if you do want to assign it, you can use script as below
%A = xof(%C);
lrGUI.GUI.InputData.Range$(ii).X$ = %a;
lrGUI.GUI.InputData.Range$(ii).Y$ = %C;
|
Clairekun |
Posted - 05/29/2014 : 03:30:54 AM Thank you for your time. I have been reading about xop X-Function; as I see it,
lrGUI.GUI.InputData.Range$(ii).Y$ = %C; only refers to Y columns in active dataset, please correct me if I'm wrong. My workbook is XY XY, so my fitting would have to include X columns. For this type of data, I always set odd columns as X and even ones as Y (I don't fully understand ii variable, but I believe this is related to it).
Again, I might be wrong since I understand little of programming, but this looks like XYYY graph fitting. |
Echo_Chu |
Posted - 05/28/2014 : 03:35:46 AM Hi,
I realized that you want to create a consolidated report for all data plot on the graph. Then you can use script as below
// GUI tree for linear fit
tree lrGUI;
// initialize the GUI tree, with the FitLinear clas
xop execute:=init classname:=FitLinear iotrgui:=lrGUI;
//Specify all data plots on graph to be input data in the GUI tree
ii = 1;
doc -e d
{
lrGUI.GUI.InputData.Range$(ii).Y$ = %C;
ii = ii + 1;
}
// perform linear fit and generate a report with the prepared GUI tree
xop execute:=report iotrgui:=lrGUI;
// clean up linear fit operation objects after fitting
xop execute:=cleanup;
Echo |
Echo_Chu |
Posted - 05/28/2014 : 02:34:41 AM As you can see in the last example of
http://www.originlab.com/doc/LabTalk/guide/Linear-Fitting
xop is an x-function to run operation classes, which is equivalent to perform linear fit via dialog.
doc -e d is to loop all data plots on graph.
tree lrGUI; // GUI tree for linear fit
doc -e d
{
// initialize the GUI tree, with the FitLinear class
xop execute:=init classname:=FitLinear iotrgui:=lrGUI;
// specify the input data in the GUI tree
lrGUI.GUI.InputData.Range1.Y$ = %C;
// perform linear fit and generate a report with the prepared GUI tree
xop execute:=report iotrgui:=lrGUI;
// clean up linear fit operation objects after fitting
xop execute:=cleanup;
} |
Clairekun |
Posted - 05/28/2014 : 02:19:15 AM Could you please explain what these code lines do, so that I can understand them fully?
How come there seems to be no straightaway code to linearly fit a set of data after creating the graph, including a table of results, referring to the worksheet used for plotting? |
Echo_Chu |
Posted - 05/27/2014 : 07:07:32 AM Hi
Could you try the script below to see whether it is what you wants
tree lrGUI; // GUI tree for linear fit
doc -e d
{
xop execute:=init classname:=FitLinear iotrgui:=lrGUI;
lrGUI.GUI.InputData.Range1.Y$ = %C;
xop execute:=report iotrgui:=lrGUI;
xop execute:=cleanup;
}
Echo OriginLab Technical Service |
Clairekun |
Posted - 05/27/2014 : 04:55:34 AM Could anyone please take a look and try to help me with this? It doesn't look like something hard to do, but I'm totally clueless.
Thanks! |
Clairekun |
Posted - 05/21/2014 : 08:35:48 AM Hello,
Thanks for your reply. Unfortunately, the links you provided don't address this issue. I have not found anything in the wiki or in any tutorial that can help me with this, so I decided to ask here in case I missed something or someone could help me with it.
|
jasonzhao |
Posted - 05/21/2014 : 06:28:04 AM Hi, You can refer to this link, which introduce ways for linear fitting by using labtalk:
http://www.originlab.com/doc/LabTalk/guide/Linear-Fitting
Furthermore, you can refer to the third example in this link to know more about loop process by using doc –ef w http://www.originlab.com/doc/LabTalk/guide/Looping-Over-objs#Looping_over_Objects_in_a_Project
Best regards, Jason Zhao OriginLab Tech Service |