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
 Origin Forum
 Plotting heatmaps with a 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

ds755

57 Posts

Posted - 04/16/2024 :  4:39:36 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

I am looking for a way to use templates when plotting heatmaps. For line plots I can write, for example:

Template$ = "<File path of template>"
range rI = [%H]1!col(C);

win -t p "%(Template$)"
page.active = 1; // activate Layer 1
layer.include(rI);


Now I am looking to do something similar with heatmaps.

I am using the following command to plot the heatmap:
plotvm irng:=2! format:=xacross rowpos:=selrow1 colpos:=selcol1 type:=105 ogl:=<new template:=Heat_Map>;


But is there a way to combine it with the win -t p command and plot a heatmap based on a saved .otpu template?

I understand that heatmaps are not plotted in the same way as lines - there's a virtual matrix involved. This makes things confusing for me.

Thanks in advance.


Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2022 (64-bit) SR1
Operating System: Windows 11 Home

YimingChen

1594 Posts

Posted - 04/16/2024 :  5:24:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
plotvm irng:=2! format:=xacross rowpos:=selrow1 colpos:=selcol1 type:=105 ogl:=<new template:=My_Heat_Map_Template>;


Go to Top of Page

ds755

57 Posts

Posted - 04/16/2024 :  5:41:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It produces an error. How can I point to the .otpu file (the exact path) using the ogl variable?
Go to Top of Page

ds755

57 Posts

Posted - 04/17/2024 :  12:00:00 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK, I figured it out. I need to set the graph name using

page.longname$ = graphname$;


and then access the graph using its name with the ogl variable.

ogl:=[graphname$]



I attach a snippet of code for whoever has the same problem in the future:

// Plot the Heat Map
TemplateGeneric$ = "%(templatepath$)Generic_Perception-test.otpu";
graphname$ = "Perception test_%(date$)_%(subject$)_%(state$)_%(frequency$)_%(totaliterations$)_%(slope$)";
Template$ = "%(templatepath$)Perception test_%(state$)_%(frequency$)_%(totaliterations$)_%(slope$).otpu"; // This is the template path


if(exist(%(uid2name(range2uid(["%(graphname$)"]))$))==0 || exist(%(uid2name(range2uid(["%(graphname$)"]))$))==2) // if there is no graph for this type of measurement (or if just a workbook with the same name exists) then create a new graph
{
	// Check if the template exists, otherwise, use a generic one
	if (exist(Template$)!=-1)// if the template exists
		win -t p "%(Template$)"; // create a graph window using template
	else
		win -t p "%(TemplateGeneric$)"; // create a graph window using a generic template
	
	page.longname$ = graphname$; //this renames the active window (long name)
	page.title = 1;  // Let the workbook title shows Long Name only (1 = Long Name, 2 = short name, 3 = both)
};
else
	win -a %(uid2name(range2uid(["%(graphname$)"]))$); // activate the graph window

win -a %(activeworkbook$);  // activate the previous window (workbook)


page.active$ = "Heat Map"; // Switch to the second worksheet (Heat Map)

// irng 2! means we choose the second sheet
// type 105 means heat map
plotvm irng:=2! format:=xacross rowpos:=selrow1 colpos:=selcol1 type:=105 ogl:=[graphname$];
layer -a;  // rescale the layer

win -a %(activeworkbook$);  // activate the previous window (workbook)
window -ch 1; // hide the workbook that was processed
Go to Top of Page

joynicholes

USA
3 Posts

Posted - 05/13/2024 :  01:31:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Python packages like Matplotlib and Seaborn can be used to plot heatmaps using a template. Here's a quick Matplotlib example:



This example shows you how to use a preset template to produce a heatmap. The template dictionary's colour mappings, axis labels, and names are all customisable to your needs. You may further expand on this example by adding more template parameters and more customisation choices.

You might investigate alternative libraries, such as Seaborn, which provides further capabilities and pre-made templates, for more sophisticated heatmap charting and customisation.
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