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
 axis ticks at the middle of the square in heatmaps
 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 - 06/28/2022 :  10:07:10 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): SR2
Operating System: Windows 10 Ent

Hi,

Is it possible to set the axis ticks at the middle of the squares in heatmaps? Instead of placing integer numbers, the ticks corresponding to the middle to the square to be displayedThis is the code I am using:

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(type='m', lname='CD-mode Heatmap Plot') # for matrices
wks.name = 'CD'
wks.from_np(CD_new)
x1,x2,y1,y2 = minx, maxx, miny, maxy
wks.xymap = x1,x2,y1,y2

gr = op.new_graph(template=('' + new_path_template + '\\Origin templates\\MMP_plot_heatmap3.otpu'))

gl_1 = gr[0]
p1 = gl_1.add_mplot(wks, 0, type = 105)
gl_1.set_ylim(min_y, max_y)
gl_1.set_xlim(min_x, max_x)
gl_1.axis('y').title = f'Y in mm ({distance_y} \u03BCm steps)'
gl_1.axis('x').title = f'X in mm ({distance_x} \u03BCm steps)'
gl_1.lt_exec("SPECTRUM1.title$=CD (mdeg);")
gl_1.rescale()
z = p1.zlevels
z['minors'] = 6
z['levels'] = [min_value_CD, min_value_CD/2, 0, max_value_CD/2, max_value_CD]
p1.zlevels = z

And the result is in the picture attached:



Thanks!

Edited by - cts18488 on 06/28/2022 10:10:52 AM

YimingChen

1618 Posts

Posted - 06/28/2022 :  11:44:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You need to set the first tick position and the tick increment. Can you add the following lines at the end of your code?

gl_1.set_float('x.inc', (maxx - minx) / 4)
gl_1.set_float('x.firstTick', minx)
gl_1.set_float('y.inc', (maxy - miny) / 4)
gl_1.set_float('y.firstTick', miny)


James
Go to Top of Page

cts18488

United Kingdom
83 Posts

Posted - 06/28/2022 :  3:24:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks. It is working. Appreciate your help, also do you know how to set up the number of decimal places? For example to 2?
quote:
Originally posted by YimingChen

You need to set the first tick position and the tick increment. Can you add the following lines at the end of your code?

gl_1.set_float('x.inc', (maxx - minx) / 4)
gl_1.set_float('x.firstTick', minx)
gl_1.set_float('y.inc', (maxy - miny) / 4)
gl_1.set_float('y.firstTick', miny)


James

Go to Top of Page

YimingChen

1618 Posts

Posted - 06/28/2022 :  4:51:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
gl_1.set_int('x.label.decPlaces', 2)
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