Graphics Reference
In-Depth Information
graph bar propval100, over(nsw) over(division) nofill asyvars
ytitle("% homes over $100K")
ylabel(0(10)80, angle(0))
The
Bar : Y-axis
(143) section also tells
us about the
ylabel()
option. In
addition to changing the labels, we also
want to change the angle of the labels,
and in that section, we see that we can
use the
angle()
option to change the
angle of the labels. Now that we have
the
80
70
60
50
40
30
20
-axis labeled as we wish, let's next
look at the title for the
y
10
-axis.
Uses allstates.dta & scheme vg past
x
0
N. Eng. Mid Atl E.N.C. W.N.C. S. Atl. E.S.C. W.S.C.Mountain
P
acific
North
South
West
graph bar propval100, over(nsw) over(division) nofill asyvars
ytitle("% homes over $100K") ylabel(0(10)80, angle(0))
b1title(Region)
After having used the
ytitle()
option
to label the
80
-axis, we might be
tempted to use the
xtitle()
option to
label the
y
70
60
-axis, but this axis is a
categorical variable. In
Bar : Cat axis
(123), we see that this axis is treated
quite differently because of that. To
put a title below the graph, we use the
b1title()
option. Now, let's turn our
attention to formatting the legend.
Uses allstates.dta & scheme vg past
x
50
40
30
20
10
0
N. Eng. Mid Atl E.N.C. W.N.C. S. Atl. E.S.C. W.S.C.MountainPacific
Region
North
South
West
graph bar propval100, over(nsw) over(division) nofill asyvars
ytitle("% homes over $100K") ylabel(0(10)80, angle(0)) b1title(Region)
legend(rows(1) position(1) ring(0))
Here, we want to use the
legend()
option to make the legend have one row
in the top right corner within the plot
area. In
Bar : Legend
(130), we see that
the
rows(1)
option makes the legend
appear in one row and that the
position(1)
option puts the legend in
the 1 o'clock position. The
ring(0)
option puts the legend inside the plot
region. Next, let's label the bars.
Uses allstates.dta & scheme vg past
80
North
South
West
70
60
50
40
30
20
10
0
N. Eng. Mid Atl E.N.C. W.N.C. S. Atl. E.S.C. W.S.C.MountainPacific
Region
The electronic form of this topic is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.