10.08.2013 Views

Introduction to Stata 8

Introduction to Stata 8

Introduction to Stata 8

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

When letting the dialog generate a simple scatterplot command, the result is like this:<br />

twoway (scatter mpg weight)<br />

twoway defines the graph type; scatter defines a plot in the graph. You could enter the<br />

same in the command window, but <strong>Stata</strong> also understands this short version:<br />

scatter mpg weight<br />

The variable list (e.g. mpg weight) in most graph commands may have one or more<br />

dependent (y-) variables, and one independent (x-) variable, which comes last.<br />

Graph commands may have options; as in other <strong>Stata</strong> commands a comma precedes the<br />

options. title() is an option <strong>to</strong> the twoway graph command:<br />

twoway (scatter mpg weight) , title("74 car makes")<br />

Plot specifications may have options. msymbol() is an option <strong>to</strong> scatter; it is located<br />

within the parentheses delimiting the plot specification. msymbol() lets you select the<br />

marker symbol (a hollow circle) <strong>to</strong> be used in the scatterplot:<br />

twoway (scatter mpg weight , msymbol(Oh))<br />

Options may have sub-options. size() is a sub-option <strong>to</strong> the title() option; here it lets<br />

the title text size be 80% of the default size:<br />

twoway (scatter mpg weight) , title("74 car makes" , size(*0.8))<br />

Warning: Options don't <strong>to</strong>lerate a space between the option keyword and the parenthesis,<br />

like the following (□ denotes a blank character):<br />

title□("74 car makes")<br />

The error message may be confusing, e.g. 'Unmatched quotes' or 'Option not allowed'.<br />

Advice: Graph commands tend <strong>to</strong> include a lot of nested parentheses, and you may make<br />

errors (I often do). In the Do-file edi<strong>to</strong>r, place the cursor after an opening parenthesis and<br />

enter [Ctrl]+B, <strong>to</strong> see the balancing closing parenthesis. In NoteTab you can use [Ctrl]+M<br />

(match) in the same way.<br />

14.4. Axis options<br />

Axis lengths<br />

Unfortunately axis lengths cannot be controlled directly, only the entire graph size. By trial<br />

and error you may then obtain the desired axis lengths. To make a graph 3 by 4 inches:<br />

twoway (scatter mpg weight) , ysize(3) xsize(4)<br />

You can, however, determine the aspect ratio of the plot area (the y/x axis ratio) by the<br />

aspect() option. To obtain a square plot area:<br />

twoway (scatter mpg weight) , ysize(3) xsize(4) aspect(1)<br />

40

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!