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
 merge graphs
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ulhong84

11 Posts

Posted - 08/09/2022 :  9:06:09 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System:OriginPro 2002 (9.9.0220)

I have ten graphs. The name of graphs is graph1, graph2, graph3..... graph10.
I merged these graphs and made the template.
How can I can merge the graphs in the code builder?



YimingChen

1618 Posts

Posted - 08/10/2022 :  08:50:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You need to call Labtalk X-fucntion from Python with lt_exec(), see the code below to merge 10 graphs:

import originpro as op
ids = list(range(1,11))
graphs = ["Graph" + str(i) for i in ids]
graphs = '\n'.join(graphs)
ltStr = f'merge_graph option:=specified option:=specified graphs:="{graphs}" row:=2 col:=5;'
op.lt_exec(ltStr)


James
Go to Top of Page

antalfee

Australia
1 Posts

Posted - 04/01/2023 :  3:01:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
To merge the graphs in code, you can use a graphing library such as Matplotlib in Python. Here is an example code snippet that shows how to merge the 10 graphs into a single template using Matplotlib:
import matplotlib.pyplot as plt

# Load each graph into a separate subplot
fig, axs = plt.subplots(2, 5, figsize=(20, 10))
axs[0, 0].imshow(graph1)
axs[0, 1].imshow(graph2)
axs[0, 2].imshow(graph3)
axs[0, 3].imshow(graph4)
axs[0, 4].imshow(graph5)
axs[1, 0].imshow(graph6)
axs[1, 1].imshow(graph7)
axs[1, 2].imshow(graph8)
axs[1, 3].imshow(graph9)
axs[1, 4].imshow(graph10)

# Hide the axis labels and ticks
for ax in axs.flat:
ax.set(xticks=[], yticks=[], xlabel='', ylabel='')

# Adjust the layout and padding of the subplots
plt.subplots_adjust(wspace=0, hspace=0, left=0, right=1, bottom=0, top=1)

# Save the merged graph as an image file
plt.savefig('merged_graphs.png', dpi=300, bbox_inches='tight')
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 04/02/2023 :  10:47:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
hi ulhong84

If the purpose is to make a template, why not do it in Origin in GUI so you can easily tweak it until it looks right?

CP
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