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
 Changing matrix dimensions and z-scale for plottin

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 - 11/17/2021 : 1:28:51 PM
Hi,

I am using the following code to generate a heatmap, however it is either the colour or the axes that are off. This is the code that I am using.

arr_x = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])
wks = op.new_sheet(type='m')
wks.from_np(arr_x)
gr = op.new_graph(template=op.path('e') + 'test_3map.otpu')
gl_1 = gr[0]
p1 = gl_1.add_mplot(wks, 0, type = 105)
gl_1.set_ylim(0.5, 4.5, 1)
gl_1.set_xlim(0.5, 2.5)

If I am using this, the x and y axes are correct, however the heatmap and the scale is not correct.
If instead of gl_1.set_xlim/ylim I am using gl_1.rescale(), the heatmap and scale are correct. Is this a way to fix this?

I am attaching few images as a proof, and a way how I can change this in Origin - if it is possible to do the same from Python straight?

Also, is there a user-manual, where it describes what each function do and how to use it with all the options? (for Python)

Thank you,
Tibi

PS: Please let me know if something is unclear.

Origin Ver.2021b and Service Release SR2
Operating System: Win 10 Ent

8   L A T E S T    R E P L I E S    (Newest First)
cts18488 Posted - 12/07/2021 : 07:54:20 AM
Thank you!

quote:
Originally posted by cpyang

We have released SR1 which fix the bug with

z['levels'] = [-8, 8]

We have replaced the 2022 installer, so just download and repair from

https://www.originlab.com/index.aspx?go=PRODUCTS%2fOrigin&pid=3292

CP


cpyang Posted - 12/02/2021 : 11:51:13 AM
We have released SR1 which fix the bug with

z['levels'] = [-8, 8]

We have replaced the 2022 installer, so just download and repair from

https://www.originlab.com/index.aspx?go=PRODUCTS%2fOrigin&pid=3292

CP
cpyang Posted - 11/26/2021 : 11:23:00 AM
Looks to me you just want more intermediate levels? Try increasing it? like


z['minors'] = 10


CP
cts18488 Posted - 11/26/2021 : 06:36:48 AM
Hi,

Thank you for that.

In the image attached I have shown what I want to do. The first heatmap is the one I can generate now. The one is the one using the intermediate (I am don't really like as there are not so many intermediates in the colour bar). The third one is a modification of the first one on which I have changed manually the minimum and maximum value.
If that can be achieved (the third heatmap) in the next update, that would be fantastic.

Regards,
Tibi



quote:
Originally posted by cpyang

Looks like there is a bug there, if you have at least one intermediate level, then it works, like [-8,0,8]

We can fix this next version.

CP


cpyang Posted - 11/25/2021 : 9:52:28 PM
Looks like there is a bug there, if you have at least one intermediate level, then it works, like [-8,0,8]

We can fix this next version.

CP
cts18488 Posted - 11/25/2021 : 5:15:12 PM
Hi,
I have one more question: is it possible to for colourbar to specify only the minimum and the maximum and the rest to be picked up by the Origin?

I have tried z['levels'] = [-8, 8], but it didn't work as I want, the colour stayed the same of template.

I appreciate the help.

Tibi
cts18488 Posted - 11/19/2021 : 10:14:36 AM
Thank you. It is working so nice.

quote:
Originally posted by cpyang

Here

import originpro as op
import numpy as np

arr_x = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])
wks = op.new_sheet(type='m')
wks.from_np(arr_x)
x1,x2,y1,y2 = 0.5, 2.5, 0.5, 4.5
wks.xymap = x1,x2,y1,y2
gr = op.new_graph(template='Heat_Map.otpu')
gl_1 = gr[0]
plot = gl_1.add_mplot(wks, 0, type = 105)
#heatmap is showing data point at the center, so need to adjust for half step size
hs = 0.5 * (x2-x1)/2;
gl_1.set_ylim(y1-hs, y2+hs, 1)
gl_1.set_xlim(x1-hs, x2+hs, 1)
#set plot colormap
z = plot.zlevels
z['minors'] = 2
z['levels'] = [1, 3,7, 8]
plot.zlevels = z
plot.colormap = 'BlueYellow.pal'



I also put this into Originlab Github sample codes area

https://github.com/originlab/Python-Samples/blob/main/4.%20Graphing/Plot%20Heatmap%20from%20Matrix%20Data.py

CP



cpyang Posted - 11/17/2021 : 4:35:10 PM
Here

import originpro as op
import numpy as np

arr_x = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])
wks = op.new_sheet(type='m')
wks.from_np(arr_x)
x1,x2,y1,y2 = 0.5, 2.5, 0.5, 4.5
wks.xymap = x1,x2,y1,y2
gr = op.new_graph(template='Heat_Map.otpu')
gl_1 = gr[0]
plot = gl_1.add_mplot(wks, 0, type = 105)
#heatmap is showing data point at the center, so need to adjust for half step size
hs = 0.5 * (x2-x1)/2;
gl_1.set_ylim(y1-hs, y2+hs, 1)
gl_1.set_xlim(x1-hs, x2+hs, 1)
#set plot colormap
z = plot.zlevels
z['minors'] = 2
z['levels'] = [1, 3,7, 8]
plot.zlevels = z
plot.colormap = 'BlueYellow.pal'



I also put this into Originlab Github sample codes area

https://github.com/originlab/Python-Samples/blob/main/4.%20Graphing/Plot%20Heatmap%20from%20Matrix%20Data.py

CP


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