Heat maps
Since heat maps encode color on a continuous scale, they are difficult to accurately decode, a topic we discussed in the first course. Hence, heat maps are most useful if you have a small number of boxes and/or a clear pattern that allows you to overcome decoding difficulties.
To produce them, map two categorical variables onto the x
and y
aesthetics, along with a continuous variable onto fill
. The geom_tile()
layer adds the boxes.
We'll produce the heat map we saw in the video (in the viewer) with the built-in barley
dataset. The barley
dataset is in the lattice
package and has already been loaded for you. Use str()
to explore the structure.
Cet exercice fait partie du cours
Intermediate Data Visualization with ggplot2
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Using barley, plot variety vs. year, filled by yield
___ +
# Add a tile geom
___