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
 All Forums
 Origin Forum for Programming
 Forum for Python
 Change tick labels heatmap

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
cts18488 Posted - 05/25/2022 : 11:14:54 AM
Origin Ver. 2022 and Service Release: SR1
Operating System: Windows 10 Enterprise

Hi,

Is it possible to change the tick labels in a heatmap with the labels defined by me (example in the picture attached)? So instead of being in sequential order like 1, 2, 3 to be like -2.5, 0, 2.5.

Thank you,
Tibi
10   L A T E S T    R E P L I E S    (Newest First)
cts18488 Posted - 05/31/2022 : 04:19:13 AM
Thanks, it worked. When I have tried I forgot to change the set_xlim and set_ylim so it didn't work.
cpyang Posted - 05/28/2022 : 2:28:29 PM
I tried the following simple code and I cannot see a problem


import originpro as op
import numpy as np

arr_2D = np.random.randint(0,4, size=(4,4))
ms = op.new_sheet('m')
ms.from_np(arr_2D)
ms.xymap = -3, 3, -3, 3
gp = op.new_graph(template='heatmap')
gp[0].add_plot(ms, colz=0)
gp[0].rescale('z')
#default XY scale will include the half width of each data point
#so to have same scale as the matrix, we need to force it
gp[0].set_xlim(-3, 3)
gp[0].set_ylim(-3, 3)



With the matrix window active, you can check the XY from
Matrix > Set Dimension/Labels

CP
cts18488 Posted - 05/27/2022 : 2:35:25 PM
Yes, I am using a matrix. And this is my setup:
wks = op.new_sheet(type='m', lname='16MM')
x1,x2,y1,y2 = 1, columns, 1, rows
wks.xymap = x1,x2,y1,y2

But if I try x1, x2, y1, y2 = -10, 10, -10, 10, It will just ignore the negative numbers and display only the positive ones.
cpyang Posted - 05/27/2022 : 1:56:53 PM
How was your data setup? Are you using a matrix? If you are using a matrix to create the heatmap, you can set the XY Mapping in the matrix, like


ms=op.find_sheet('M')
ms.xymap = x1, x2, y1, y2


CP
cts18488 Posted - 05/27/2022 : 07:30:16 AM
quote:
Originally posted by YimingChen

For your case, you can use Label Display Formula instead. See the figure below. If this works for you, do you want to customize the axis label with Python code? as you can save that setting into a template.

Thanks.

James






This is not what I want as the dimension may change and instead of having a 41x41 heatmap, I might have a 81x81 heatmap. So instead of having from -2.5 to 2.5 in one case, in others I may have from -4 to 0. Label display formula works on individual cases, but not on automation mode.

Is it possible to give in Python the limits (let's say xmin and xmax) and then Origin to consider this as the new 1 and the new 41 (if one has 41 inputs on an axis); then Origin to split them at regular intervals?

Thank you!
YimingChen Posted - 05/26/2022 : 12:19:46 PM
For your case, you can use Label Display Formula instead. See the figure below. If this works for you, do you want to customize the axis label with Python code? as you can save that setting into a template.

Thanks.

James


cts18488 Posted - 05/26/2022 : 08:42:36 AM
I have tried your suggestion, however it doesn't work how I was imagine. If I change the tick labels from 5 10 15 20 25 30 35 40 to -4 -3 -2 -1 0 1 2 3, everything works fine. If I want to zoom in, let's say 20 to 30, the tick labels do no work the way I want. Instead of displaying -1 0 1, it displays labels from beginning -4 -3 -2. Is it possible to display the way I want (I am attaching a picture that describe the issue I have)? Also, in case of numbers, if I give a minimum and a maximum number, is it possible that Origin generates automatically the rest of the labels at regular intervals, but the same number of labels as the original ones?

Thank you for all your help!
Tibi
cpyang Posted - 05/25/2022 : 9:05:54 PM
Yes, this can be done, but will need to use some LabTalk. Basically you put the tick label values into a worksheet column and then tell the axis to use Tick Indexed Dataset as the labels, such that first label will use text from row 1 etc.

We will put together sample code to Github and put the link here shortly.

In the meantime, you can look at this for the GUI interface.

https://www.originlab.com/doc/Origin-Help/AxesRef-TickLabels

and look for Tick Indexed Dataset option.

CP
cts18488 Posted - 05/25/2022 : 5:59:21 PM
Hi. Sorry for the confusion. You are right; I don't want to change the x-scale, but only the labels. I want to generate/change myself all labels instead, in this case all 8 tick labels. Instead of being 5 10 15... 40, I would like something like -4 -3 -2...3 Please let me know if it is possible.
YimingChen Posted - 05/25/2022 : 1:53:41 PM
The question is on which ticks do you want to put the labels -2.5, 0, 2.5? The x-axis has 8 ticks with labels. You don't want to change the x scale, but only labels? Please clarify.

James

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000