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
 Can't plot 8x12 graphs using template
 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 - 01/20/2023 :  10:49:48 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 2021b and Service Release (Select Help-->About Origin):
Operating System: Win 10 ent

Hi,

I am trying to plot a 8x12 plots (see picture attached) using originpro module in python and a template. However, when the software is trying to plot the graph I get the following error:
gl_0 = gr1[0]
TypeError: 'NoneType' object is not subscriptable

If I try a 4x4 plot, everything is working fine. Appreciate any help.

The code is below:


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 = 'HTCD') # for normal plots
wks.name = 'HTCD'

wks.from_list(0, htcd_file[0], lname='Wavelength', units='nm')

for i in range(1, 97):
    wks.from_list(i, htcd_file[i], lname=f'{i}', comments=f'spectrum {i}')


path_template = os.getcwd()

new_path_template = path_template.replace('/', '\\')

gr1 = op.new_graph(template=(new_path_template + '\\Origin templates\\htcd.otpu'), lname='HTCD')
      
gl_0 = gr1[0]
g0 = gl_0.add_plot(wks, coly='B', colx='A', type=202)

gl_1= gr1[1]
p1 = gl_1.add_plot(wks, coly='C', colx='A', type=202)




Edited by - cts18488 on 01/20/2023 10:54:19 AM

YimingChen

1617 Posts

Posted - 01/20/2023 :  3:06:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I couldn't reproduce the issue. Can you share the graph template (htcd.otpu) for us to test? Thanks.

James
Go to Top of Page

cts18488

United Kingdom
83 Posts

Posted - 01/21/2023 :  3:11:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here it is the template
quote:
Originally posted by YimingChen

I couldn't reproduce the issue. Can you share the graph template (htcd.otpu) for us to test? Thanks.

James

https://my.originlab.com/ftp/forum_and_kbase/Images/htcd.otpu
Go to Top of Page

cts18488

United Kingdom
83 Posts

Posted - 01/23/2023 :  09:08:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have solved the problem. The issue was related with the current directory hence the graph template was not read. Sorry and thank you for your help.
quote:
Originally posted by cts18488

Origin Ver. 2021b and Service Release (Select Help-->About Origin):
Operating System: Win 10 ent

Hi,

I am trying to plot a 8x12 plots (see picture attached) using originpro module in python and a template. However, when the software is trying to plot the graph I get the following error:
gl_0 = gr1[0]
TypeError: 'NoneType' object is not subscriptable

If I try a 4x4 plot, everything is working fine. Appreciate any help.

The code is below:


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 = 'HTCD') # for normal plots
wks.name = 'HTCD'

wks.from_list(0, htcd_file[0], lname='Wavelength', units='nm')

for i in range(1, 97):
    wks.from_list(i, htcd_file[i], lname=f'{i}', comments=f'spectrum {i}')


path_template = os.getcwd()

new_path_template = path_template.replace('/', '\\')

gr1 = op.new_graph(template=(new_path_template + '\\Origin templates\\htcd.otpu'), lname='HTCD')
      
gl_0 = gr1[0]
g0 = gl_0.add_plot(wks, coly='B', colx='A', type=202)

gl_1= gr1[1]
p1 = gl_1.add_plot(wks, coly='C', colx='A', type=202)





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