Send an Invite      Sign in   
Tuhunga logo
Sign up now

Visualizing data with heatmaps

Written by Jason on August 24, 2010

We’re going to introduce a new dataset for today’s example. Much of the data from the CIA’s World Factbook is available at Tuhunga for free, and we’re going to use it to demonstrate heatmaps. In this example, we’re going to visually compare the population of a country against the population growth rate.

Specifically, we’re going to plot the population as the size of the box, and the rate of change as the color. But, of course, the size and color can be any numeric data you wish. In the example below, we show the ten most populous countries in the world, and underneath, we’ll up the chart to show all the countries with populations over ten million to demonstrate how large sets are drawn.

Compared to the ten-point plot above, there are 82 countries with over 10 million people, and the graph below becomes crowded. However, it remains useful. With careful selection of the maximum and minimum colors, as well as the value range to shade over (values outside this range use the same color as the two extremes), we can still see trends, even if the names of the countries are not visible. Hovering over an item in the graph will reveal the full label.

For this example, we have used a value range of +3 to -3, with red at -3 and green at +3. To ensure that it fits within the width of almost all viewers of the blog, we have used a 550 pixel graph width. However, if your application has greater leeway, the extra horizontal space will permit more of the label name to be displayed.

As is customary for these posts, we’ll provide filter and report details so you may recreate it yourself. The following steps assume that you are familiar with the concepts covered in Tutorial #1.

First Graph


  • PopulationRank<=10 (top 10 countries ranked by population in descending order)


  • Population
  • PopulationGrowth
  • concat(Country,": ",round(Population/1000000,0)," @ ",round(PopulationGrowth,1),"%") (see below)

We'll pause for a moment to discuss the concat() function. It will combine multiple text strings into one - and in our example, combines the Country name, a colon and space, the Population, shown in millions by dividing and rounded off all the decimals, the "at" sign, a rounded PopulationGrowth, and a percent sign. Concat() is useful at times like this when it is desirable to include multiple elements in a human-readable label.

After enabling graphing, we'll use the Heat Map type and set the Label to the concat()'d report item, Size to Population, and Value (aka color) to PopulationGrowth. The options tab has the maximum and minimum values we wrote about earlier, and we set those to +3 and -3, respectively. The colors for those values may be changed on the Labels tab.

Second Graph


  • Population>10000000 (retrieve countries with over 10 million people)

The report is the same as the one above.

Tags: analysis, charts, examples

  About    Contact    Legal    Privacy    Follow us on Twitter  

© 2009 - 2013. All Rights Reserved.