Hierarchical Clustering and Heat Maps in Mathematica

Hierarchical clustering is a way to expose the hidden structure of a complex, high-dimensional dataset. Heat maps are a common way to visualize the results of such clustering algorithms. This Demonstration shows how to use the HierarchicalClustering package in Mathematica to generate heat maps with the dendrograms included on the sides of the heat map.
Specifically, a sample distribution (pictured on the left) is uniformly sampled with an added noise term (proportional to the sliders in the - and directions) in an " sampling density" by " sampling density" grid. The resulting matrix of function values is then hierarchically clustered in both the rows and the columns, often revealing a relatively simple underlying structure to the originally complex-structured data. You can vary the noise, the functions used in the hierarchical clustering, and the structure of the underlying distribution being sampled to see how these algorithms are both sensitive to the inputs given and powerful when used properly.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


This Demonstration is based on a program originally presented on the Mathematica Stack Exchange blog by user verbeia, incorporating the edits suggested by user kguler and several original modifications. The original blog post can be found at [1].
A word of caution: Only the functions contained in this notebook are fully accurate in terms of matching the dendrograms to the displayed data. The previous implementations mentioned are not correct. While the author wants to give attribution to others' code, it should not be used unless corrected in the manner shown above.
[1] verbeia. "Turning Up the Heat Maps." Mathematica Stack Exchange. (Jun 10, 2015) mathematica.blogoverflow.com/2012/10/turning-up-the-heat-maps.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2017 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+