How to easily make beautiful heatmaps with ezplot - Part 8
byGuangming Lang
4 min read
Categories
r
Updated October 4, 2018
In this post, we’ll look at how to make effective heatmaps using ezplot. We’ll
use a dataset of NBA players’ statistics from flowingdata.com. Make sure you
first install ezplot by running the command devtools::install_github("gmlang/ezplot").
Let’s get the data. Notice we pass the url directly to read.csv().
The variable Name has the names of the NBA players. By default, it’s treated
by R as a Factor with levels ordered alphabetically. Reorder its levels by
points scored.
The other variables are various performance statistics. Before we can make a
heat map, we need to put the data in the long format. In other words, we need to
gather the names of the statistics in one column, and their values in another column.
We also want to scale the values of each performance statistics so that they are
between 0 and 1.
With all these data prep work done, we’re ready to make a heatmap. This is super
easy with ezplot.
Not it’s your turn. Make a heat map using the unscaled values, and compare it
with the scaled version. You will see they are very different. The scaled
version is the mathematically correct one.
This is the last post in the ezplot how-to series. If you’ve enjoyed it,
tell your friend about it. If you want to learn more about how to use
ezplot, you can get my book here.