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
 Adding Reference Line with Label Programmatically
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jodokusquack

Austria
3 Posts

Posted - 07/14/2023 :  05:37:36 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin):OriginPro 2022 (64-bit) SR1
Operating System: Windows 11

Hi, I am using external python and the originpro package to automatically import my data and create plots from this data.

I am now trying to add Reference Lines with a label at specific x-positions just like it is possible from the Axis dialog box under the 'Reference Lines' tab.

So far, I have only found the X-function 'addline' which I was able to call from Python but this did not allow me to have arbitrary labels for the line.

Is there a possibility to automatically add Reference lines at some given x-values with String-labels also provided from the Python program?

Thanks in advance for any help.

YimingChen

1618 Posts

Posted - 07/18/2023 :  3:56:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Could you try the Python script below?

import originpro as op
gl = op.new_graph()[0]
gl.set_int('x.reflines.count',1)
gl.set_int('x.reflines.lineshow',1)
gl.set_float('x.refline1.value',4)
gl.set_int('x.refline1.labelshow',1)
gl.set_str('x.refline1.labeltext','abc')


James

Edited by - YimingChen on 07/18/2023 4:10:16 PM
Go to Top of Page

jodokusquack

Austria
3 Posts

Posted - 07/19/2023 :  11:33:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Nice, it works! Thank you very much for the script.

Would it also be possible to rotate the label so that they are displayed vertically?

In some of my plots the labels overlap if I add too many and having them vertically would be more space-saving.
Go to Top of Page

YimingChen

1618 Posts

Posted - 07/19/2023 :  2:43:06 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Try the script below

import originpro as op
gl = op.new_graph()[0]
gl.set_int('x.reflines.count',1)
gl.set_int('x.reflines.lineshow',1)
gl.set_float('x.refline1.value',4)
gl.set_int('x.refline1.labelshow',1)
gl.set_str('x.refline1.labeltext','abc')
gl.lt_exec("RLX1.rotate=90") ## RLX1 is the object name of the label


quote:
Originally posted by jodokusquack

Nice, it works! Thank you very much for the script.

Would it also be possible to rotate the label so that they are displayed vertically?

In some of my plots the labels overlap if I add too many and having them vertically would be more space-saving.


Edited by - YimingChen on 07/19/2023 2:43:37 PM
Go to Top of Page

jodokusquack

Austria
3 Posts

Posted - 07/20/2023 :  03:27:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much for the help!
This works too.
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