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
 Forum for Python
 How to add report table in Graph by embeddedpython

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
changyue Posted - 05/24/2021 : 08:23:39 AM
I execute a Nolinear curve fiting by originpython. I can add the fitting curve in the graph, but I also want to add a report table in the gaph as the result fitted by GUI operation. Could anyone tell me how to add the report table in the graph?

model=op.NLFit('Lorentz')
model.set_data(wks, 0, 1)
model.fit()
r, c = model.report(True)
wReport=op.find_sheet('w', r)
wCurves=op.find_sheet('w', c)
p=gl.add_plot(wCurves, 1, 0)
p.color='red'

2   L A T E S T    R E P L I E S    (Newest First)
minimax Posted - 05/24/2021 : 10:05:06 PM
Hi changyue,

In Origin2021b with originpro v1.0.6, you can try to create the plot with source data first and then fit from graph, where the table will be added onto graph by default. like


import os
import originpro as op

wks = op.new_sheet()
wks.from_file(os.path.join(op.path('e'), 'Samples', 'Curve Fitting', 'Gaussian.dat'))
graph = op.new_graph(template='scatter')
gl=graph[0]
dp = gl.add_plot(wks, 1, 0)
gl.rescale()
model=op.NLFit('Lorentz')
model.set_range(f'{gl}!{dp.index() + 1}')
model.fit()
r, c = model.report(True)
YimingChen Posted - 05/24/2021 : 09:20:05 AM
We may need to improve this part. Right now we can add table using X-function add_table_to_graph, X-function can be called in Python with lt_exec method, try the Python script below:


op.lt_exec('add_table_to_graph cols:=2 row:=10 tabname:=tt;') # add table using Labtalk
tn = op.get_lt_str('tt') # get the table name
wb=op.find_book(name=tn) # find the table by its name
df = wReport.report_table('Notes') # dataframe to put to the table
wb[0].from_df(df)


In the script, you can customize the dataframe to be put to the table.

James

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