Simple Heat Map

The following graph shows how a heat map bar graph can be used to compare variables of two different categories. This specific graph shows the wage comparisons for married and non married individuals in terms of the years of education undertaken.

The following code can be implemented in Stata to produce the graph above:

sysuse nlsw88, clear
drop if grade < 8
collapse wage, by(grade married)
replace wage = round(wage,.01)
summarize wage
generate colour = round((wage-r(min))/(r(max)-r(min))*255)
levelsof colour, local(levels)
local start
foreach colour of local levels {
	local colour1 = 120+round(`colour'/2)
	local colour2 = 255-round(`colour'/2)
	local start = `"`start'"' + `"scatter married grade if colour == `colour', msymbol(square) msize(ehuge) mcolor("`colour2' `colour2' `colour1'") || "'
}

`start' scatter married grade, symbol(i) mlabel(wage) mlabposition(0) mlabcolor(black) legend(off) ylabel(-.75 "" 0 "N" 1 "Y" 1.75 "", notick) xlabel(7 "" 8/18 19 "", notick) title(Wage Heat Map)