definition - mistake - related - code


A heatmap is a graphical representation of data where the individual values contained in a matrix are represented as colors. It is a bit like looking a data table from above.

Here is an example showing 8 general features like population or life expectancy for about 30 countries in 2015. Data come from the French National Institute of Demographic Studies.

Note: You can learn more about this dataset and how to visualize it in the dedicated page

What for

Heatmap is really useful to display a general view of numerical data, not to extract specific data point. In the graphic above, the huge population size of China and India pops out for example.

Heatmap is also useful to display the result of hierarchical clustering. Basically, clustering checks what countries tend to have the same features on their numeric variables, what countries are similar. The usual way to represent the result is to use dendrogram. This type of chart can be drawn on top of the heatmap:

Here, Afghanistan, India and Bolivia are grouped together. Indeed they are 3 countries in strong expansion, with a lot of children per woman but still a strong mortality rate.

Note: in this heatmap, features are also clusterised. For instance, life expectancy and mortality rate are grouped together since they are highly correlated.

Note: hierarchical clustering is a complex statistical method. You can learn more about it here.


Common mistakes


Build your own

The R and Python graph galleries are 2 websites providing hundreds of chart example, always providing the reproducible code. Click the button below to see how to build the chart you need with your favorite programing language.

R graph gallery Python gallery

#Comments *** Any thoughts on this? Found any mistake? Disagree? Please drop me a word on twitter or in the comment section below:


A work by Yan Holtz for data-to-viz.com