Graphics Reference
In-Depth Information
twoway (bar malmil agegrp, horizontal) (bar femmil agegrp, horizontal)
(scatter agegrp zero, msymbol(i) mlabel(agegrp) mlabcolor(black)),
xlabel(-12 "12" -8 "8" -4 "4" 4 8 12) xtitle("Population in millions")
y scale(off) ylabel(, nogrid) legend(order(1 "Male" 2 "Female"))
We suppress the display of the
-axis
using the yscale(off) option and
suppress the grid lines with the
ylabel(, nogrid) option. Finally, we
use the legend() option to label the
bars and suppress the display of the
third symbol in the legend.
Uses pop2000mf.dta & scheme s2color
y
80 to 84
75 to 79
70 to 74
65 to 69
60 to 64
55 to 59
50 to 54
45 to 49
40 to 44
35 to 39
30 to 34
25 to 29
20 to 24
15 to 19
10 to 14
5 to 9
Under 5
12
8
4
4
8
12
Population in millions
Male
Female
11.5
Common mistakes
This section discusses mistakes that are frequently made when creating Stata graphs.
Using Stata 7 syntax
No matter how long we have been using Stata 8 (or later), we might revert back to old
habits and type a graph command in Stata 7 style. Consider this example:
. graph propval100 rent700
Stata replies with this error message:
propval100graph g.new rent700: class member function not found
r(4023);
Clearly, the easiest solution is to convert the command to the proper Stata 8 syntax.
Commas with graph options
With Stata 8, graph options can accept their own options (sometimes referred to as
suboptions ); for example,
. twoway scatter propval100 popden rent700, xtitle("My Title", box)
Note that the xtitle() option allows us to specify the
x
-title followed by a comma and
a further suboption that places a box around the
x
-title. If we had been content with the
existing
x
-title, we could have issued this command:
. twoway scatter propval100 popden rent700, xtitle( , box)
The electronic form of this topic is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.
Search WWH ::




Custom Search