top of page
Search
  • Writer's pictureMaia

What is Heatmap and How to use it in Python

What is Heatmap?

A Heat Map is a graphical representations of data that utilize color-coded systems.

The data values are contained in a matrix formEach data value is represented as a color in a color-coding scheme. The darker the shade, the greater the quantity; the higher the value, the tighter the dispersion, or vice versa etc.Perfect for representing data where a defined boundary is relevant to the data (which is marked and bounded area on a map denoting the distribution of some property).Website tracking and tools to optimize conversions.

Some examples of Heatmap

This Heatmap shows relatively how much investment returns have been generated between the sectors by months.

This Heatmap is displaying the dates and times whereby the store is most heavily trafficked. Immediately identify which dates and hours are busiest.

The Heat Map indicates approximate values. The darker the shade, the greater the number of population.

In the Website User Interaction Heatmap below, it visualizes relatively how much attention the users paid between the areas on the website.

How to use Heatmap in Python using the Seaborn visualization library?

First, we need to import Seaborn library. And, remember Seaborn is built on top of Matplotlib, so we need to include the magic command Matplotlib to show inline graphs in Jupyter notebook.

The data table above shows the feature of number of passengers that flied in each month of each year. But the data table is not in matrix form, we need to convert it into a matrix form with index is the months and columns are the years by using a Pivot table.

Now we see the data in a matrix form where each data value (each cell) is the number of passengers flied for the month on that row and the year on that column.

With this matrix data, we can easily plot a Heatmap for it using Seaborn’s Heatmap plot.

In the Heatmap above, we see that the color-coding legend is showed on the right of the map. The colors go from dark to light which the higher the data values the lighter the colors.

But if we want, we can change to another color map to show from cool to warm, the higher the data values the warmer the colors, then we can customize the Heatmap as below.

We can also choose whether or not we want to show the data value on each cell of the Heatmap.

Now, we look at the Heatmap of the dataset ‘flights’ again to see what it tells us.

The very first thing we see is that the later the year the more people fly, this make sense because over time the flights is more accessible to people. The second thing we notice is that in any given year, the months of July and August tend to have much more people fly than other months. This also make sense because that the summer time where families tend to have more long vacation trips.

CONCLUSION

ADVANTAGES:

Display a more generalized view of numeric values.Extremely versatile and efficient in drawing attention to trends.Reliance on color to communicate values, self-explanatory, result is a data visualization that quickly communicates its data to the viewer.

DISADVANTAGES:

Do not distinguish between a single person looking at a spot for a long time and a group of people looking at a spot for a moment.

Happy visualizing!





Recent Posts

See All

댓글


Post: Blog2_Post
bottom of page