Introduction to Stata 8 - (GRIPS
Introduction to Stata 8 - (GRIPS
Introduction to Stata 8 - (GRIPS
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
twoway<br />
scatter<br />
Mileage (mpg)<br />
40<br />
30<br />
20<br />
10<br />
2,000 3,000 4,000 5,000<br />
Weight (lbs.)<br />
/ / c:\dokumenter\...\gph.mpg_weight.do<br />
clear<br />
sysuse<br />
au<strong>to</strong><br />
set<br />
scheme lean2<br />
Domestic<br />
Foreign<br />
twoway ///<br />
(scatter mpg weight if foreign==0, msymbol(Oh)) ///<br />
(scatter mpg weight if foreign==1, msymbol(O)) ///<br />
, ///<br />
legend(label(1 "Domestic") label(2 "Foreign")) ///<br />
xsize(4) ysize(2.3) scale(1.4)<br />
Twoway graphs have continuous x- and y-axes; scatter is the "mother" of twoway graphs.<br />
A graph with one plot has no legend; this one with two plots has. The default legend texts<br />
often need <strong>to</strong> be replaced by short, distinct texts, like here. Since the xtitle() and<br />
ytitle() options were not specified, <strong>Stata</strong> used the variable labels as axis titles.<br />
msymbol may be abbreviated <strong>to</strong> ms; I chose <strong>to</strong> avoid abbreviations for readability; it is<br />
much more important that commands are easy <strong>to</strong> read than easy <strong>to</strong> write. In this case the<br />
msymbol() options were not necessary since (Oh) and (O) are the default first symbols<br />
under the lean schemes.<br />
The graph displays the same data as the initial Figure 1, this time using the scheme lean2:<br />
The plot area has horizontal grid-lines, but no frame.<br />
45