Graphics Reference
In-Depth Information
twoway tsline price, by(compname, cols(1) yrescale note("") compact)
ylabel(#2, nogrid) subtitle(, pos(5) ring(0) nobexpand nobox color(red))
title(" ", box width(130) height(.001) bcolor(ebblue))
We graph
price
for the different
companies with the
by()
option.
Further,
cols(1)
puts the graphs in
one column.
yrescale
and
ylabel(#2)
allow the
alpha
-axes to be scaled
independently and labeled with about 2
values. The
subtitle()
option puts
the name of the company in the
bottom, right corner of each graph. The
title()
option creates an empty title
that is thin, wide, and blue. Combined
with the
compact
option, the title
creates a border between the graphs.
Uses comp2001ts.dta & scheme vg s2c
y
beta
mu
sigma
1Jan01
1Apr01
1Jul01
1Oct01
1Jan02
Date
For the next graph, we want to create a bar chart that shows the mean of wages by
occupation with error bars showing a 95% confidence interval for each mean. To do this,
we first collapse the data across the levels of occupation, creating the mean, standard devi-
ation, and count. Next, we create the variables
wageucl
and
wagelcl
, which are the upper
and lower confidence limits, as shown below.
. vguse allstates
. collapse (mean) mwage=wage (sd) sdwage=wage (count) nwage=wage, by(occ7)
. generate wageucl = mwage + invttail(nwage,0.025)*sdwage/sqrt(nwage)
. generate wagelcl = mwage - invttail(nwage,0.025)*sdwage/sqrt(nwage)
After this, we are ready to execute the following command:
twoway (bar mwage occ7, barwidth(.5))
(rcap wageucl wagelcl occ7, blwid(medthick) blcolor(navy) msize(large)),
xlabel(1(1)7, valuelabel noticks) xscale(range(.5 7.5))
This bar chart is overlaid with a range
plot showing the upper and lower
confidence limits. The
xlabel()
option
labels the values from 1 to 7,
incrementing by 1. The
valuelabel
option indicates that the value labels
for
occ7
will be used to label the
x
-axis. The
xscale()
option adds a
margin to the outer bars, and the
barwidth()
option creates the gap
between the bars.
Uses allstates.dta & scheme vg s2c
Prof
Mgmt
Sales
Cler.
Operat.
Labor
Other
Occupation recoded into 7 categories
(mean) wage
wageucl/wagelcl
The electronic form of this topic is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.