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 text in Origin graph

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
cts18488 Posted - 06/27/2022 : 09:24:04 AM
Origin Ver. 2021b and Service Release (Select Help-->About Origin):
Operating System: Windows 10 Enterprise

Hi,

I want to add a text in an Origin graph in a specific place (see picture attached). However, the text will be different from graph to graph as I want the text to be the title of the file so to avoid any confusion in the future (especially when I export the files in a powerpoint presentation). So would it be possible to do this using python to add the text in that position? Or alternatively to set the text box in the position I want in the template and modify the text in Python?

Thanks,
Tibi
3   L A T E S T    R E P L I E S    (Newest First)
YimingChen Posted - 06/27/2022 : 5:16:21 PM
go.set_int('fsize', 22)

set_int() method here is to set graph object properties using Python. You can find the list of graph object property on this page:
https://www.originlab.com/doc/LabTalk/ref/Graphic-objs

James
cts18488 Posted - 06/27/2022 : 5:00:28 PM
Thanks. And how do I set the fontsize? I had a look in the link you posted, but couldn’t spot it. Is it \p200?
YimingChen Posted - 06/27/2022 : 11:37:26 AM
You may call Labtalk script from Python to add text at the specified position. Try the example Python code below:

import originpro as op
graph = op.new_graph()
gl = graph[0] 
gl.lt_exec(f'label text_to_add') ## add label to the layer.
go = gl.label('text') ## get the text object
go.set_int('left', 2840) ## set text position
go.set_int('top', 5000) 
go.set_int('attach', 0) ## attach the text object to layer
gl.lt_exec('pfit2l') ## fit the page to layers

Here Labtalk command label is called from Python to place the label. Please refer to the page on the label command.
https://www.originlab.com/doc/LabTalk/ref/Label-cmd

James

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