Hi,
This is the code that I am using - it is a bit long:
def origin_shutdown_exception_hook(exctype, value, traceback):
'''Ensures Origin gets shut down if an uncaught exception'''
op.exit()
sys.__excepthook__(exctype, value, traceback)
if op and op.oext:
sys.excepthook = origin_shutdown_exception_hook
if op.oext:
op.set_show(True)
wks = op.new_sheet(lname = f'16MM {session_name2}') # for normal plots
wks.name = 'M00'
wks.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks.from_list(1, M00_list[0], lname='M00', comments='M00')
wks_M01 = wks.get_book().add_sheet('M01')
wks_M01.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M01.from_list(1, M01_list[0], lname='M01', comments='M01')
wks_M02 = wks.get_book().add_sheet('M02')
wks_M02.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M02.from_list(1, M02_list[0], lname='M02', comments='M02')
wks_M03 = wks.get_book().add_sheet('M03')
wks_M03.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M03.from_list(1, M03_list[0], lname='M03', comments='M03')
wks_M10 = wks.get_book().add_sheet('M10')
wks_M10.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M10.from_list(1, M10_list[0], lname='M10', comments='M10')
wks_M11 = wks.get_book().add_sheet('M11')
wks_M11.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M11.from_list(1, M11_list[0], lname='M11', comments='M11')
wks_M12 = wks.get_book().add_sheet('M12')
wks_M12.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M12.from_list(1, M12_list[0], lname='M12', comments='M12')
wks_M13 = wks.get_book().add_sheet('M13')
wks_M13.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M13.from_list(1, M13_list[0], lname='M13', comments='M13')
wks_M20 = wks.get_book().add_sheet('M20')
wks_M20.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M20.from_list(1, M20_list[0], lname='M20', comments='M20')
wks_M21 = wks.get_book().add_sheet('M21')
wks_M21.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M21.from_list(1, M21_list[0], lname='M21', comments='M21')
wks_M22 = wks.get_book().add_sheet('M22')
wks_M22.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M22.from_list(1, M22_list[0], lname='M22', comments='M22')
wks_M23 = wks.get_book().add_sheet('M23')
wks_M23.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M23.from_list(1, M23_list[0], lname='M23', comments='M23')
wks_M30 = wks.get_book().add_sheet('M30')
wks_M30.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M30.from_list(1, M30_list[0], lname='M30', comments='M30')
wks_M31 = wks.get_book().add_sheet('M31')
wks_M31.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M31.from_list(1, M31_list[0], lname='M31', comments='M31')
wks_M32 = wks.get_book().add_sheet('M32')
wks_M32.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M32.from_list(1, M32_list[0], lname='M32', comments='M32')
wks_M33 = wks.get_book().add_sheet('M33')
wks_M33.from_list(0, Wavelength_new, lname='Wavelength', units='nm')
wks_M33.from_list(1, M33_list[0], lname='M33', comments='M33')
if len(M00_list) > 1:
for i in range(1, len(M00_list)):
wks.from_list(i+1, M00_list)
wks_M01.from_list(i+1, M01_list[i])
wks_M02.from_list(i+1, M02_list[i])
wks_M03.from_list(i+1, M03_list[i])
wks_M10.from_list(i+1, M10_list[i])
wks_M11.from_list(i+1, M11_list[i])
wks_M12.from_list(i+1, M12_list[i])
wks_M13.from_list(i+1, M13_list[i])
wks_M20.from_list(i+1, M20_list[i])
wks_M21.from_list(i+1, M21_list[i])
wks_M22.from_list(i+1, M22_list[i])
wks_M23.from_list(i+1, M23_list[i])
wks_M30.from_list(i+1, M30_list[i])
wks_M31.from_list(i+1, M31_list[i])
wks_M32.from_list(i+1, M32_list[i])
wks_M33.from_list(i+1, M33_list[i])
path_template = os.getcwd()
new_path_template = path_template.replace('/', '\\')
gr = op.new_graph(template=(new_path_template + '\\Origin templates\\test_plot16 - normalisation.otpu'), lname=f'16MM plot{session_name2}')
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M00'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_1 = gr[0]
p1 = gl_1.add_plot(f'{wks.lt_range()}!(?,1:end)')
p1.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_1.set_int("x.AtZero",1)
gl_1.group()
p1.colormap = 'Candy'
gl_1.rescale()
gl_1.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M00 = gr[0].label('Legend')
lgnd_M00.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M01'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_2 = gr[1]
p2 = gl_2.add_plot(f'{wks_M01.lt_range()}!(?,1:end)')
p2.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_1.set_int("x.AtZero",1)
gl_2.group()
p2.colormap = 'Candy'
gl_2.rescale()
gl_2.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M01 = gr[1].label('Legend')
lgnd_M01.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M02'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_3 = gr[2]
p3 = gl_3.add_plot(f'{wks_M02.lt_range()}!(?,1:end)')
p3.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_3.set_int("x.AtZero",1)
gl_3.group()
p3.colormap = 'Candy'
gl_3.rescale()
gl_3.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M02 = gr[2].label('Legend')
lgnd_M02.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M03'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_4 = gr[3]
p4 = gl_4.add_plot(f'{wks_M03.lt_range()}!(?,1:end)')
p4.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_4.set_int("x.AtZero",1)
gl_4.group()
p4.colormap = 'Candy'
gl_4.rescale()
gl_4.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M03 = gr[3].label('Legend')
lgnd_M03.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M10'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_5 = gr[4]
p5 = gl_5.add_plot(f'{wks_M10.lt_range()}!(?,1:end)')
p5.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_5.set_int("x.AtZero",1)
gl_5.group()
p5.colormap = 'Candy'
gl_5.rescale()
gl_5.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M10 = gr[4].label('Legend')
lgnd_M10.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M11'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_6 = gr[5]
p6 = gl_6.add_plot(f'{wks_M11.lt_range()}!(?,1:end)')
p6.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_6.set_int("x.AtZero",1)
gl_6.group()
p6.colormap = 'Candy'
gl_6.rescale()
gl_6.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M11 = gr[5].label('Legend')
lgnd_M11.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M12'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_7 = gr[6]
p7 = gl_7.add_plot(f'{wks_M12.lt_range()}!(?,1:end)')
p7.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_7.set_int("x.AtZero",1)
gl_7.group()
p7.colormap = 'Candy'
gl_7.rescale()
gl_7.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M12 = gr[6].label('Legend')
lgnd_M12.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M13'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_8 = gr[7]
p8 = gl_8.add_plot(f'{wks_M13.lt_range()}!(?,1:end)')
p8.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_8.set_int("x.AtZero",1)
gl_8.group()
p8.colormap = 'Candy'
gl_8.rescale()
gl_8.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M13 = gr[7].label('Legend')
lgnd_M13.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M20'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_9 = gr
p9 = gl_9.add_plot(f'{wks_M20.lt_range()}!(?,1:end)')
p9.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_9.set_int("x.AtZero",1)
gl_9.group()
p9.colormap = 'Candy'
gl_9.rescale()
gl_9.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M20 = gr.label('Legend')
lgnd_M20.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M21'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_10 = gr[9]
p10 = gl_10.add_plot(f'{wks_M21.lt_range()}!(?,1:end)')
p10.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_10.set_int("x.AtZero",1)
gl_10.group()
p10.colormap = 'Candy'
gl_10.rescale()
gl_10.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M21 = gr[9].label('Legend')
lgnd_M21.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M22'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_11 = gr[10]
p11 = gl_11.add_plot(f'{wks_M22.lt_range()}!(?,1:end)')
p11.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_11.set_int("x.AtZero",1)
gl_11.group()
p11.colormap = 'Candy'
gl_11.rescale()
gl_11.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M22 = gr[10].label('Legend')
lgnd_M22.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M23'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_12 = gr[11]
p12 = gl_12.add_plot(f'{wks_M23.lt_range()}!(?,1:end)')
p12.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_12.set_int("x.AtZero",1)
gl_12.group()
p12.colormap = 'Candy'
gl_12.rescale()
gl_12.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M23 = gr[11].label('Legend')
lgnd_M23.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M30'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_13 = gr[12]
p13 = gl_13.add_plot(f'{wks_M30.lt_range()}!(?,1:end)')
p13.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_13.set_int("x.AtZero",1)
gl_13.group()
p13.colormap = 'Candy'
gl_13.rescale()
gl_13.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M30 = gr[12].label('Legend')
lgnd_M30.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M31'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_14 = gr[13]
p14 = gl_14.add_plot(f'{wks_M31.lt_range()}!(?,1:end)')
p14.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_14.set_int("x.AtZero",1)
gl_14.group()
p14.colormap = 'Candy'
gl_14.rescale()
gl_14.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M31 = gr[13].label('Legend')
lgnd_M31.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M32'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_15 = gr[14]
p15 = gl_15.add_plot(f'{wks_M32.lt_range()}!(?,1:end)')
p15.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_15.set_int("x.AtZero",1)
gl_15.group()
p15.colormap = 'Candy'
gl_15.rescale()
gl_15.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M32 = gr[14].label('Legend')
lgnd_M32.text = ' %(1)'
poz = 0
neg = 0
for i in range(len(csv_file)):
if csv_file['M33'][i] > 0:
poz = poz + 1
else:
neg = neg + 1
gl_16 = gr[15]
p16 = gl_16.add_plot(f'{wks_M33.lt_range()}!(?,1:end)')
p16.set_int('line.width', 3)
if (neg >= 1) and poz >=1:
gl_16.set_int("x.AtZero",1)
gl_16.group()
p16.colormap = 'Candy'
gl_16.rescale()
gl_16.xlim = (min(csv_file['Wavelength']), max(csv_file['Wavelength']))
lgnd_M33 = gr[15].label('Legend')
lgnd_M33.text = ' %(1)'
if op.oext:
op.exit()
quote:
[i]Originally posted by minimax
Would you mind to show the context py scripts which dump the error msg, so that we can check in details?