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

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
ds755 Posted - 04/16/2024 : 4:39:36 PM
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
4   L A T E S T    R E P L I E S    (Newest First)
joynicholes Posted - 05/13/2024 : 01:31:36 AM
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.
ds755 Posted - 04/17/2024 : 12:00:00 AM
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
ds755 Posted - 04/16/2024 : 5:41:17 PM
It produces an error. How can I point to the .otpu file (the exact path) using the ogl variable?
YimingChen Posted - 04/16/2024 : 5:24:35 PM
plotvm irng:=2! format:=xacross rowpos:=selrow1 colpos:=selcol1 type:=105 ogl:=<new template:=My_Heat_Map_Template>;



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