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
 Forum for Python
 How to add report table in Graph by embeddedpython
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

changyue

1 Posts

Posted - 05/24/2021 :  08:23:39 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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'

YimingChen

1618 Posts

Posted - 05/24/2021 :  09:20:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - YimingChen on 05/24/2021 09:21:39 AM
Go to Top of Page

minimax

351 Posts

Posted - 05/24/2021 :  10:05:06 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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)
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