Graphics Reference
In-Depth Information
7
Pie graphs
This chapter discusses the use of pie charts in Stata. We start by illustrating the different
kinds of ways that you can create pie charts in Stata, followed by showing how you can sort
the slices in your pie charts. Next, we show how you can customize the display of individual
slices, as well as control the colors of the pie chart. Then, we demonstrate different ways
you can label the pie slices and then how you can control the legends for pie charts. Finally,
we discuss how to use the by() option.
7.1
Types of pie graphs
This section describes different ways to produce pie charts using Stata. Stata allows you
to produce pie charts based on multiple
y
-variables, with each
y
-variable corresponding to
a slice. You can also create a pie chart based on a single
-variable broken down by a single
over() variable. Finally, you can create a pie chart with no
y
-variables broken down by
an over() variable, which counts the number of observations by each level of the over()
variable. For more details, see [ G ] graph pie . This section uses the vg s1c scheme.
y
graph pie poplt5 pop5 17 pop18 64 pop65p
In this syntax, you supply multiple
y
-variable
corresponds to a slice in the pie. The
first
-variables, and each
y
-variable is the population in the
state that is younger than 5 years old,
the next the population 5 to 17 years
old, the next 18 to 64 years old, and the
last 65 years and older. The entire pie
would correspond to the sum of all of
these variables across all states. The
first slice then corresponds to the
percentage of the total population that
is younger than 5 years old.
Uses allstates.dta & scheme vg s1c
y
Pop, < 5 year
Pop, 5 to 17 years
Pop, 18 to 64 years
Pop, 65 and older
217
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