Pie diagrams
Pie diagrams are useful to depict proportions. There are three common applications:
- Sum up values for a list of variables and display the total of a variables values as the fraction of the sum of all totals (makes only sense if variables have same scale)
- Sum up values for one variable over categories
- Depict relative frequencies for one variable
* Pie diagrams
sysuse census, clear
// Show totals or percentages of each variable
// The variables to be displayed have to make sense when combined to a total!
graph pie poplt5 pop5_17 pop18p
// Add percentage to slices and title
graph pie poplt5 pop5_17 pop18p, plabel(_all percent) title("Population by age group")
// Sum up values for one variable over categories
graph pie pop, over(region) plabel(_all percent) title ("Share of the population by region")
// Depict relative frequencies for one variable
graph pie, over(region) plabel(_all sum) title("Distribution of states by region")
// Highlight specific slices
graph pie, over(region) plabel(_all sum) title("Distribution of states by region") pie(1, explode) pie(2, explode)
Exercise
Open the pre-installed dataset voter.dta. The dataset contains US voting results for the candidats Clinton, Bush and Perot by income group.
- Inspect the dataset to see what each variable records.
- Create pie diagrams for the lowest and the highest income quintile, indicating the fraction of votes each canditate could win within the income group
- Modify the graph to include a label with the respective % to each slice
- Add a title to each graph