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
 Alter Plot's 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

i.reuter

12 Posts

Posted - 08/10/2021 :  05:34:56 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I need to plot several regions of the same column. The following code works fine to create the demanded plot:


graph = op.new_graph(template='scatter')
gl=graph[0]
for index, halfcycle in halfcycles.iterrows():
    if index%10 == 0:
        plot = gl.add_plot(f'[Book1]Sheet1!("current_interpolated","potential_interpolated")[{halfcycle["start"]}:{halfcycle["end"]}]', type='s')
gl.group(True,0,-1)
gl.rescale()


Unfortunately, this creates a legend with the same entry (column name) for each plot. I cannot find a way to create a legend like this:
- Potential (halfcycle 0)
* Potential (halfcycle 10)
# Potential (halfcycle 20)
x ...
Where the number represents the value of the index variable in the for-loop above.

Any help is very much appreciated.


Origin Ver. and Service Release: 2021b / 9.8.5.201
Operating System: Windows 10 / 1809ESR

YimingChen

1620 Posts

Posted - 08/10/2021 :  09:23:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You may create a string and pass it to lgnd.text. See the Python example:
https://www.originlab.com/doc/python/Examples/Graphing#Multiple_Layer_Plot

For the legend entry syntax, you may refer to:
https://www.originlab.com/doc/LabTalk/ref/Legend-Substitution-Notation

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