Graphics Reference
In-Depth Information
graph display
This is the graph that we wish to
create. For now, we simply use the
graph display command to display
the graph. Because this is displayed
using the s2color scheme, the size of
the text is not enlarged as in the other
vg schemes, so the text may be hard to
read.
Uses pop2000mf.dta & scheme s2color
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
To build this graph, we first use the data file pop2000mf , which contains 17 observa-
tions corresponding to 17 age groups (for example, “Under 5”, “5 to 9”, “10 to 14”, and so
forth). The variables femtotal and maletotal contain the number of females and males in
each age group. After using the file, we create femmil , which is the number of females per
million, and malmil , which is the number of males per million, but this is made negative so
that the male (blue) bar will be scaled in the negative direction. We also make a variable
zero , which contains 0 for all observations.
. vguse pop2000mf
. gen femmil = femtotal/1000000
. gen malmil = -maletotal/1000000
. gen zero = 0
We now take the first step in making this graph.
twoway (bar malmil agegrp) (bar femmil agegrp)
This is our first attempt to make this
graph by overlaying the bar chart for
the males with the bar chart for the
females. The agegrp variable ranges
from1to17andformsthe
-axis, but
we can rotate this as shown in the next
example.
Uses pop2000mf.dta & scheme s2color
x
0
5
10
15
20
Age category
malmil
femmil
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