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
 centred title
 New Topic  Reply to Topic
 Printer Friendly
Author  Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cts18488

United Kingdom
91 Posts

Posted - 09/03/2026 :  10:52:05 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver.2024b
Operating System:Win 11

Hi,

Is there a way to keep the graph title always centred at the top using python? I know how to set its position, but the alignment changes significantly when the title length varies, for example from 20 to 50 characters. Also, how can I introduce a new line in title, in case it is too long? So it doesn't elongate the layer without reason

Edited by - cts18488 on 09/03/2026 3:36:10 PM

NadeeshaSupport

USA
16 Posts

Posted - 09/04/2026 :  2:41:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Page title will position the title at the center top and auto wrap. To add a Page Title, click the top edge of the graph to open the Mini Toolbar, then select Add Page Title.

The following Python example may also be helpful.

1. Open Python Console from the Connectivity menu
2. Enter the following commands one at a time:

import originpro as op
gp = op.new_graph(template='scatter')
gl = gp[0]
gl.lt_exec('label -j 1 -sa -n MyTitle This is a very long graph title\\nfor testing title wrapping in Origin;')
gl.lt_exec('MyTitle.x = layer.x.from + (layer.x.to-layer.x.from)/2;')
gl.lt_exec('MyTitle.y = layer.y.to + MyTitle.dy/2;')


The text inside the quotes in the fourth line is LabTalk:
label = creates a text label
-j 1 = center alignment
-sa = use \n as a line break
-n MyTitle = names the object MyTitle

Thanks,
Nadeesha
Go to Top of Page

NadeeshaSupport

USA
16 Posts

Posted - 09/04/2026 :  5:36:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Please also try the following using the Python console from the Connectivity menu.

import originpro as op
gp = op.new_graph(template='scatter')
gl = gp[0]
gl.lt_exec('page.ptitle = 1;')
gl.lt_exec('page -s;')
gl.lt_exec('_ptitle.text$ = "This is the first line%(CRLF)This is the second line";')
gl.lt_exec('layer.top = layer.top + 5;')

I left the last four lines as separate so you can see what each command is doing. The last four lines can also be combined into a single command:
gl.lt_exec('page.ptitle = 1; page -s; _ptitle.text$ = "This is the first line%(CRLF)This is the second line"; layer.top = layer.top + 5;')

Thanks,
Nadeesha
Go to Top of Page
   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