T O P I C R E V I E W |
pavi-chem |
Posted - 05/29/2023 : 3:32:09 PM Hi Origin community,
i am trying to use a python program to batch process my FTIR spectra data using an origin graph template, the problem i am facing is the style of the plot is changed when it applying the data to my template. i am unsure why this happens, the lines are thicker width in the 3d waterfall plot. so, any advice on how to apply the template style to the plot would be great.
My code: import originpro as op import os import tkinter as tk from tkinter import filedialog
# Very useful, especially during development, when you are # liable to have a few uncaught exceptions. # Ensures that the Origin instance gets shut down properly. # Note: only applicable to external Python. import sys
def origin_shutdown_exception_hook(exctype, value, traceback): """Ensures Origin gets shut down if an uncaught exception""" op.exit() sys.__excepthook__(exctype, value, traceback)
sys.excepthook = origin_shutdown_exception_hook
# Only run if external Python if op.oext: op.set_show(True)
# Prompt user to select an Origin template file for graph 2 root = tk.Tk() root.withdraw() template_file_path2 = filedialog.askopenfilename(title="Select Origin Template File for Graph 2", filetypes=[("Origin Template Files", "*.otpu")])
# Prompt user to select an XLSX file for the second graph xlsx_file_path = filedialog.askopenfilename(title=f"Select XLSX File for {os.path.basename(template_file_path2)}", filetypes=[("XLSX Files", "*.xlsx")])
# Load the XLSX file into a new worksheet wks2 = op.new_sheet() wks2.from_file(xlsx_file_path, False)
# Create a new graph using the selected template for graph 2 gr2 = op.new_graph(template=template_file_path2)
# Define the range of columns (1-12) for the y-axis y_columns = list(range(1, 13)) # Adjust the range as needed
for col in range(1, 13): # Adjust the range as needed plot = gr2[0].add_plot(wks2, 0, col, col+1) template_plot = gr2[0].plots[col-1] # Get the corresponding plot in the template plot.style.copy_from(template_plot.style) # Copy the plot style from the template plot
gr2[0].rescale()
# Tile all windows op.lt_exec('win-s T')
# Prompt user for the output Origin file name root = tk.Tk() root.withdraw() output_file_path = filedialog.asksaveasfilename(title="Save Output Origin File", filetypes=[("Origin Project Files", "*.opju")])
# Save the project to the specified output file path using both op.oext and op.save if op.oext: op.save(os.path.abspath(output_file_path)) else: gr.save(os.path.abspath(output_file_path)) gr2.save(os.path.abspath(output_file_path))
Thanks a bunch! Pavi. |
10 L A T E S T R E P L I E S (Newest First) |
pavi-chem |
Posted - 06/14/2023 : 08:58:43 AM omg, it worked!!
Thank you soo much :)
Thanks a bunch! Pavi. |
YimingChen |
Posted - 06/14/2023 : 08:45:45 AM Could you replace the line
plot = gl.add_plot(wks2, 0, col, col+1) by
plot = gl.add_plot(wks2, col, 0)
Thanks,
quote: Originally posted by pavi-chem
Hi,
Still same problem but the plot is colourful now. I added the excel file, outpur origin file and the program to the google drive folder, could you please check what is wrong? [https://drive.google.com/drive/folders/1iTsgu27A215BDKowbooem94HnQgGe1pY?usp=drive_linkl]
Thanks a bunch! Pavi.
|
pavi-chem |
Posted - 06/14/2023 : 06:21:49 AM Hi,
Still same problem but the plot is colourful now. I added the excel file, outpur origin file and the program to the google drive folder, could you please check what is wrong? [https://drive.google.com/drive/folders/1iTsgu27A215BDKowbooem94HnQgGe1pY?usp=drive_linkl]
Thanks a bunch! Pavi. |
YimingChen |
Posted - 06/13/2023 : 12:40:58 PM Can you go to the menu Preferences->Theme Organizer... and check if you set a system theme. If so, find the theme and right-click on it to clear the system theme.
James |
pavi-chem |
Posted - 06/13/2023 : 11:42:55 AM Hi James,
Sorry for the delay in response. I am still getting the same issue. Do you not get the issue with the project when you run it? the graph plot looks normal without the thick lines?
Thanks for any advice.
Thanks a bunch! Pavi. |
YimingChen |
Posted - 06/01/2023 : 5:29:39 PM Can you try the script below with the worksheet activated? I still couldn't reproduce your issue.
import os
import originpro as op
# Import the data file
wks = op.find_sheet()
# Create a graph page
graph = op.new_graph(template='glWater3D')
gl=graph[0]
for col in range(1, wks.cols):
plot = gl.add_plot(wks, col, 0)
gl.rescale()
James |
pavi-chem |
Posted - 06/01/2023 : 4:20:15 PM Here is my project. https://my.originlab.com/ftp/forum_and_kbase/Images/june1-test7.opju
Thanks a bunch! Pavi. |
YimingChen |
Posted - 06/01/2023 : 2:25:59 PM If you simply execute the script I provided. Does it work?
Could you send me the project file with the wrong graph plotted?
Thank you James |
pavi-chem |
Posted - 06/01/2023 : 07:26:41 AM Hi James,
Thanks for the response. I tried your code without using my custom template. one without gl.group() and one with gl.group().
Both graphs looks same problem with thick line widths and filled in black. the graph using gl.group() has a colour filled lines.
If I plot them manually they look fine, so i am not sure what the issue is.
Any other suggestion please?
Thanks a bunch! Pavi. |
YimingChen |
Posted - 05/30/2023 : 11:21:50 AM I couldn't reproduce the issue that the line width is different. Could you please try the sample code below? I used the system 3D waterfall graph template. Maybe you were using a customized graph template which caused the issue. Thank you.
James
import os
import originpro as op
# Import the data file
wks = op.new_sheet()
wks.from_file(os.path.join(op.path('e'), 'Samples', 'Curve Fitting', 'Linear Fit.dat'))
# Create a graph page
graph = op.new_graph(template='glWater3D')
gl=graph[0]
for col in range(1, 4):
plot = gl.add_plot(wks, col, 0)
gl.group()
gl.rescale()
|
|
|