graph scatter
Shows how two numbers move together, one dot per record. Add fit for the straight line through them and how much of the movement it explains.
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 scatter y x [if], [fit]
y first, then x, as in Stata. fit adds the least-squares line with its R-squared. No weights. Past 5,000 points a random 5,000 are drawn (the fit still uses all of them).
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 |
|---|---|---|
education | a number | across the bottom |
mpce | a number | up the side (y comes first in the command) |
Three rows of it would look like this:
8 2410.55 12 4102.8 5 2988.1
The example
. sysuse vira.sample01, clear . graph scatter mpce education, fit
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.