graph stackarea
Bands stacked over time, showing both the total and how the composition shifted. The time axis must be a number.
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 stackarea [(stat)] varname [if] [weight], over(xvar) by(bandvar)
Bands stacked along a numeric xvar (a year, an age). (sum) by default or (count).
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 |
|---|---|---|
year | a number | along the bottom (over); it must be a number |
sector | a category | the bands stacked at each year (by) |
mpce | a number | added up for each band; use (count) to count rows |
Three rows of it would look like this:
2004 Rural 2410.55 2004 Urban 3288.1 2006 Rural 2598.4
The example
. sysuse vira.sample01, clear . graph stackarea (count) mpce, over(year) by(sector)
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.