| Author |
Topic  |
|
|
cts18488
United Kingdom
91 Posts |
Posted - 09/03/2026 : 10:52:05 AM
|
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
|
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
|
 |
|
|
NadeeshaSupport
USA
16 Posts |
Posted - 09/04/2026 : 5:36:04 PM
|
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 |
 |
|
| |
Topic  |
|