Graphics Reference
In-Depth Information
11.4
Putting it all together, more examples
Most of the examples in this topic have focused on the impact of a single option or a
small number of options, using datasets that required no manipulation prior to making the
graph. In reality, many graphs use multiple options together, and some require prior data
management. This section addresses this issue by showing some examples that combine
numerous options and require some data manipulation before making the graph.
twoway (scatter urban pcturban80) (function y=x, range(30 100)),
xtitle(Percent Urban 1980) ytitle(Percent Urban 1990)
legend(order(2 "Line where % Urban 1980 = % Urban 1990") pos(6) ring(0))
This graph shows the percentage of
population living in an urban area of a
state in 1990 against that of 1980. If
there had been no changes from 1980 to
1990, the values would fall along a
45-degree line, where the value of
y
equals the value of
.Overlaying
(function y=x) ,wecanseeany
discrepancies from 1980 to 1990. The
range(30 100) option makes the line
span from 30 to 100 on the
x
Line where % Urban 1980 = % Urban 1990
-axis.
Uses allstates.dta & scheme vg s2c
x
20.0
40.0
60.0
80.0
100.0
Percent Urban 1980
twoway (lfitci ownhome borninstate) (lfitci ownhome borninstate,
ciplot(rline) blcolor(blue) blwidth(thick) blpattern(dash))
(scatter ownhome borninstate), legend(off) ytitle("% Own Home")
This example shows how we can make a
scatterplot, a regression line, and a
confidence interval for the fit shown as
an area. We also add a thick, blue,
dashed line showing the upper and
lower confidence limits. The first
lfitci makes the fit line and area; the
second lfitci makes a thick, blue,
dashed outline for the area; and
scatter overlays the scatterplot.
Uses allstates.dta & scheme vg s2c
20
40
60
80
% born in state of residence
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