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
 Set up the legend
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cts18488

United Kingdom
83 Posts

Posted - 11/29/2021 :  11:36:32 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

I have a series of spectra and for each spectrum Origin is generating a line in legend. Is there a way in Python to show the legend for only a spectrum and remove the line before the name? I want to use the legend as a title, as there is not a lot of space to set up the title for each graph (please see the first line of graphs in the picture for more information)

Thank you,
Tibi


Origin Ver. 2021b and Service Release: SR2
Operating System: Win 10 Ent

YimingChen

1621 Posts

Posted - 11/29/2021 :  5:05:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You need to obtain the legend object for each layer and change its text. Try the code below:

for gl in gp:
    lgnd = gl.label('Legend')
    lgnd.text=' \l(1) %(1)'


Must have something different from internal "\l(1) %(1)" to prevent auto expending so I just added a space, but you can add a caption or whatever as long as it is different from the generic internal form

We added this as another sample on github

https://github.com/originlab/Python-Samples/blob/main/4.%20Graphing/Graph%20Legend%20to%20Show%20Only%20First%20Plot.py

James

Edited by - YimingChen on 11/29/2021 5:05:36 PM
Go to Top of Page

cts18488

United Kingdom
83 Posts

Posted - 12/07/2021 :  07:24:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you a lot!

quote:
Originally posted by YimingChen

You need to obtain the legend object for each layer and change its text. Try the code below:

for gl in gp:
    lgnd = gl.label('Legend')
    lgnd.text=' \l(1) %(1)'


Must have something different from internal "\l(1) %(1)" to prevent auto expending so I just added a space, but you can add a caption or whatever as long as it is different from the generic internal form

We added this as another sample on github

https://github.com/originlab/Python-Samples/blob/main/4.%20Graphing/Graph%20Legend%20to%20Show%20Only%20First%20Plot.py

James

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