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
 LabTalk Forum
 create heatmap using labtalk
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

TitoK

Austria
6 Posts

Posted - 04/12/2015 :  09:01:16 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2015
Operating System: Windows 7

I use LabView to acquire data and create Origin worksheets and line and bar plots from this data using plotxy.

Also I'm capable of creating matrix sheets. Now I'd like to create a heatmap from the data of a matrix using labtalk - how can I do this?
Which plotfunction (plotxy, plotxyz,...) do I need?

Shirley_GZ

China
Posts

Posted - 04/13/2015 :  06:53:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Titok,

Origin don't have a X-Function (such as plotxy) which can be used to plot heatmap graph, But you can try to use the below script to execute the script in the [HeatMap] section of the Plot3D.OGS.

run.section(Plot3D,HeatMap);


http://www.originlab.com/doc/LabTalk/ref/Run-obj

Thanks,

Originlab Technical Service Team
Go to Top of Page

TitoK

Austria
6 Posts

Posted - 04/15/2015 :  10:24:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Thanks for the reply - this almost seems to be what I'm looking for.

I tried the command and ended up with an empty heat map.

So far what I do is the following: I create a matrix book with several sheets (for now I tried this using just one sheet). I'd like to create a heatmap from every matrix sheet.

Currently from LabView I first create all the sheets, then my idea was to activate the first sheet and use the 'run.section...' command just like it is written in the last post (I do similar - create workbooksheets and then within a loop I create a graph page, activate a sheet and create a bar graph from that in another program).

Just this time activating the sheet is not enough it seems. Do I have to pass the sheetname or something as an argument maybe, if so how do I do this? I took a look into the Plot3D.OGS but I couldn't figure out how it really works so far.

When I create the heat map manually it works without problems.
Go to Top of Page

Shirley_GZ

China
Posts

Posted - 04/16/2015 :  04:10:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I suppose that you want to plot all matrixsheets in all matrixbooks in current project. Please try the below script lines:

doc -e M{
doc -e LW{
run.section(Plot3D,HeatMap);
}
}


Any problem, please let me know.

Originlab Technical Service Team

Edited by - Shirley_GZ on 04/16/2015 04:10:30 AM
Go to Top of Page

TitoK

Austria
6 Posts

Posted - 04/24/2015 :  10:08:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Shirley_GZ,

Thanks for the help. The script is basicaly doing what it should. Now I'd only need to adjust the graphs. So far I managed to change the x and y axis labels, what I'd still need to figure out is:

The heatmap should be in grey scales, not in color.

Each graph should have the same name as the corresponding matrix sheet it is created from (all are from the same matrix book).

The x and y scales should correspond to the data of the matrix. For example I just created a heatmap from a matrix with 2 columns and 5 rows. In the heatmap I get a grid with 2x5 squares with the color representing the values in the cells of the matrix - so far so good. But the x and y scale are going from 1 to 10. Moreover on the x axis the two columns are only located from the scale value 0,9 to 1,4. On the y axis the rows are aligned from 0,9 to 2,3. I'd like every square to be represented as 1 unit on the scale - so the first square of the first column should correspond to 1 on the x scale and 1 on y, the second square in the first column should be 2 on x and still 1 on the y scale and so on.

Is there a way to do this using Labtalk?

Thanks,
Tito
Go to Top of Page

SeanMao

China
288 Posts

Posted - 04/28/2015 :  11:03:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

The code would be following:


doc -e M{
doc -e LW{
matrix -ps Y 1 $(wks.nRows); // Set Y from 1 to Y dimension
matrix -ps X 1 $(wks.nCols); // Set X from 1 to X dimension
string msname$ = wks.name$; // Current Matrix Sheet Name
run.section(Plot3D,HeatMap); // Make HeatMap plot
page.title = 1; // Use Long Name as window title
page.longname$ = msname$; // Set Graph Window Name as Matrix Sheet Name
layer.x.minorticks=0; // No minor ticks on X axis
layer.y.minorticks=0; // No minor ticks on Y axis
layer.x.inc=1; // Major tick increment is 1 on X axis
layer.y.inc=1; // Major tick increment is 1 on Y axis
set %C -cpal grayscale; // Set Color Palette to be GrayScale
}
}


This code will loop through all matrix sheets in all matrix books and make a grayscale heatmap with matrix sheet name as graph window name.

A sample image is shown below:



Regards!

Sean

Edited by - SeanMao on 04/28/2015 11:08:08 PM
Go to Top of Page

TitoK

Austria
6 Posts

Posted - 04/29/2015 :  07:01:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Sean,

Thank you very much! I figured out, the problem with the scale was that I didn't set the matrix dimension correctly. Now I do and it works perfectly.

Is it possible to reverse to the scale color - so to go from white (lowest value) to black? I found the option in Origin itself, but I cannot figure out so far how to change it using labtalk - I took a look at the set command and layer.cmap but I didn't find it.

Also so far I had no luck changing the color scale title - I'd like it to be 'Counts' for all graphs. I think it cannot be to hard, but I'm rather new to Origin/ Labtalk, so sorry for all the questions. ;-)



Go to Top of Page

SeanMao

China
288 Posts

Posted - 05/03/2015 :  10:39:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

The LabTalk control for flipping the color scale and to set the title for it are not supported yet.

It is an known issue that we are already considering implementing. Right now you can only manually set it.

Regards!

Sean
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