A Matrix Heat Map in Stata

This heat map is similar to the matrix plot we created in a previous graph. It plots the values, or relative “heat” level, of each XY coordinate in your dataset. This type of heatmap is best used on small datasets, where each XY coordinate has only one value.

To create this graph in Stata, you first need to download the hmap command from the SSC, which you can do within Stata using the following command:

ssc install hmap

To generate this graph in Stata, use the following commands:

clear all
set obs 64
set seed 45678
generate n = runiformint(1,8)
egen x = seq(), from(1) to(8) block(8)
egen y = seq(), from(1) to(8) block(1)
label define xlab 1 "one" 2 "two" 3 "three" 4 "four" 5 "five" 6 "six" 7 "seven" 8 "eight"
label values x xlab
table y x [fw=n]
hmap x y n