Graphics Reference
In-Depth Information
This next graph shows a kind of scatterplot of the mean and confidence interval for
union and collgrad for each level of occ7 . To do this, we collapse the data file by occ7
and use those summary statistics to compute the confidence intervals below, followed by
the command to create the graph.
. vguse nlsw
. collapse (mean) pct un=un pct coll=collgrad
(sd) sd un=union sd coll=collgrad
(count) ct un=union ct coll=collgrad, by(occ7)
. gen lci un = pct un - sd un/sqrt(ct un)
. gen uci un = pct un + sd un/sqrt(ct un)
. gen lci coll = pct coll - sd coll/sqrt(ct coll)
. gen uci coll = pct coll + sd coll/sqrt(ct coll)
twoway (rcap lci coll uci coll pct un) (rcap lci un uci un pct coll, hor)
(sc pct coll pct un, msymbol(i) mlabel(occ7) mlabpos(10) mlabgap(5)),
ylabel(0(.2).7) xtitle(% Union) ytitle(% Coll Grads) legend(off)
titl e("% Union and % college graduates" "(with CIs) by occupation")
The overlaid rcap commands show the
confidence intervals for both union and
collgrad for each occupation. The
scatter command uses an invisible
marker and labels each occupation at
the 10 o'clock position with a larger
gap than normal.
Uses .dta & scheme vg s2c
% Union and % college graduates
(with CIs) by occupation
Other
Prof
Mgmt
Cler.
Sales
Labor
Operat.
0
.1
.2
.3
.4
% Union
This section concludes with a graph adapted from an example on the Stata web site.
The graph combines numerous tricks, so rather than show it all at once, let's build it up a
piece at a time. Below is the ultimate graph we would like to create. It shows the population
(in millions) for males and females in 17 different age groups, ranging from “Under 5” up
to “80 to 84”. The blue bar represents the males, and the red bar represents the females.
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