Monthly Archives: July 2017

R: Heatmap plots

I’m working with a dataset of trace-metals concentrations in different streams, and I wanted to see the overall mean concentration for each metal, in each stream. I used a heatmap┬áto plot a grid of streams vs. metals, with a color shading in each cell representing the mean concentration.

Heatmap - wet weather metals

Light blue values are lower concentrations, dark red values are higher concentrations (grey cells contain no data). Since some metals occur at much higher concentrations than others (by a few orders of magnitude), all the data have been scaled (more on the methods below) — which is why the heatmap does not have a legend with actual values. It’s purely a high-low gradient.

Metals are in alphabetical order down the left-hand side. Streams are across the top, sorted so that the streams with the overall highest metals concentrations are on the left, going to the overall lowest metals concentrations on the right.

There are several webpages with instructions on how to build a heatmap like this in R, using ggplot2, and I’ve made my own modifications to both the aesthetics and the data-handling. Continue reading

Advertisements

Leave a comment

Filed under Data graphs, R