Graphics Programs Reference
In-Depth Information
FIGurE 7-6 Heatmap using custom red color scale
If you don't want to pick your own colors, you can also use the
RColorBrewer package. The package is not installed by default, so you
need to download and install it via the Package Installer if you haven't
already. ColorBrewer was designed by cartographer Cynthia Brewer and
was originally intended for maps, but it can help you create data graphics
in general. You can choose from a variety of options, such as a sequen-
tial or divergent color palette and number of shades. For the purposes
of this example, go with a simple blue palette. enter ?brewer.pal in the
R console for more options—it's fun to play with. Assuming you installed
RColorBrewer, enter the following for a heatmap using a blue palette with
nine shades. The result is shown in Figure 7-7.
P Visit the
interactive ver-
sion of Color-
brewer at http://-
colorbrewer2.com .
You can select
options from
drop-down menus
to see how color
schemes look in a
sample map.
library(RColorBrewer)
bball_heatmap <- heatmap(bball_matrix, Rowv=NA,
Colv=NA, col = brewer.pal(9, “Blues”),
scale=”column”, margins=c(5,10))
Search WWH ::




Custom Search