graph heatmap
A grid coloured by value, for two categories at once. Reads well when there are too many combinations for bars — states by years, departments by months.
What we have
- statistics:
count,max,mean,median,min,sum over()for the categories andby()for a second splittitle(),ytitle()andsaving()- one self-contained
.htmlfile: no server, no internet, nothing to install - a table view beside the chart, so the numbers can be read off
Coming later
- saving as PNG or SVG —
graph exportdoes not exist yet graph twowayandgraph matrix, which are refused- 84 more of the 105 catalogue chart types
How you write it
graph heatmap [(stat)] varname [if] [weight], over(rowvar) by(colvar)
A grid coloured by the statistic.
What your data has to look like
One row per person or record, with these columns (named here as they are in vira.sample01):
| Column | Holds | What it does in the chart |
|---|---|---|
state | a category | the rows of the grid (over) |
year | a category | the columns of the grid (by); a number with a few values works too |
mpce | a number | the average that colours each cell |
Three rows of it would look like this:
Bihar 2004 2410.55 Bihar 2006 2598.4 Kerala 2004 4102.8
The example
. sysuse vira.sample01, clear . graph heatmap mpce, over(state) by(year)
That is the real file the command wrote — open it on its own. It is one self-contained page with no internet connection needed, so you can email it or drop it into a report.