Documentation

13A.17 Tile heatmaps and two-dimensional summaries

The tile geom creates a rectangular grid from x and y categories. With a fill variable, each cell shows its mean; without fill, it shows the count. This makes tile useful for sampling coverage, mean response by dose and nominal time, missingness patterns, or categorical cross-classifications.

Mean concentration by time and dose

The example forces time and dose to categories with factor(). Each tile therefore represents a dose-time cell and fill is the mean DV among retained observation rows. The plot is not an interpolated surface, and adjacent colors do not imply values between sampled cells.

Continuous fill uses a gradient, normally viridis. Choose a palette that remains readable for color-vision deficiencies and grayscale reproduction. A diverging bluered palette is appropriate only when a meaningful center such as zero exists; a sequential palette better represents concentration magnitude.

Empty cells can mean no rows, all missing fill values, or filtering. Distinguish structural absence from zero. Provide a companion pivot/count table when exact values or denominators matter. With too many x/y categories, labels and tiles become unreadable; bin or derive clinically meaningful categories upstream rather than silently truncating.

Review the colour scale endpoints as carefully as the cells. An extreme cell can compress all other variation, while panel-specific or manually narrowed scales can exaggerate small differences. Preserve a consistent scale across comparable heatmaps and note any transformation, especially log concentration or standardized residuals.

Common mistakes

  • Reading an empty tile as zero.
  • Treating a categorical grid as continuous interpolation.
  • Choosing a diverging palette without a meaningful midpoint.
  • Comparing cell colors without cell counts.

Checklist

  • Define x and y categories explicitly.
  • State whether fill is mean or count.
  • Inspect missing and empty cells.
  • Provide exact values or N in a table.
  • Use an accessible palette and readable labels.

Further reading

See pivot tables, palettes, missingness, and aesthetics.