View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Heat Maps with Text

5.0 | 3 ratings Rate this file 12 Downloads (last 30 days) File Size: 46.5 KB File ID: #15877 Version:
image thumbnail

Heat Maps with Text


Robert Henson (view profile)


09 Aug 2007 (Updated )

Heat maps with numeric values overlayed

Editor's Notes:

This was a File Exchange Pick of the Week

| Watch this File

File Information

A number of people have asked me whether MATLAB can add text to heatmaps to show the exact values. This is very easy to do, however, making a the text robust to resizing, zooming and other operations is a little trickier.
This example shows how to add text to the heatmap and also includes an M-file that shows how to handle zooming and resizing.


This file inspired Scattertext.

MATLAB release MATLAB 7.4 (R2007a)
Other requirements This was created with R2007a but should run with version back to R14.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
21 Aug 2014 Casper S√łnderby

Great function. Line 88 could be changed to something like:
textHandles(j,i) = text(j,i,sprintf(['%.' num2str(precision) 'f'],data(i,j)),...

Then the numeric precision is counting from the decimal point

Comment only
21 Sep 2011 Tristan

Is there a way to make this function robust to a change of figure units to centimeters?

23 Mar 2011 Matlab2010

PS. to be able to use XtickLabel etc to name the axis after making this image, type "axis on"

Comment only
23 Mar 2011 Matlab2010


17 Aug 2007 Dimitri Shvorob

Useful, instructive, and nicely presented.

23 Jul 2013 1.1

Added BSD license

01 Sep 2016

Updated license

Contact us