O'Reilly logo

R Data Visualization Cookbook by Atmajitsinh Gohil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating a heat map with customized colors

In the previous recipe, we prepared our data and created a heat map. The heat map was constructed using the default color scheme. What if we would like to plot a heat map using a softer colors? This recipe dives into plotting a heat map by customizing colors. The heat map for Iraq body count is as follows:

Generating a heat map with customized colors

Getting ready

For implementing a customized color scheme in our heat map, we require the following two packages available developed for R:

  • pheatmap
  • RColorBrewer

How to do it…

We start the recipe by installing the necessary packages and loading the same in our active R session:

install.packges(c("pheatmap","RColorBrewer")) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required