Soci 109: Sample graph commands

Lane Kenworthy
Soci 109: Analysis of Sociological Data
Winter 2020

Scatterplots

Line graphs

Dot plots

DOES THE ECONOMY INFLUENCE PRESIDENTIAL ELECTION OUTCOMES?

Figure 20. Income growth and presidential election outcomes
Vertical axis: incumbent-party candidate’s popular vote margin. Data source: Wikipedia. Horizontal axis: growth rate of real disposable personal income per capita in the second and third quarters of the election year, adjusted for incumbency (-1.29 for each consecutive term, beyond the first, that the incumbent party has held the White House). Data source: Bureau of Economic Analysis, bea.gov, using National Income and Product Accounts (NIPA) data. The correlation is .91. This replicates and extends Larry Bartels’ chart in “Obama Toes the Line,” The Monkey Cage, 2013. For more detail, see Christopher Achen and Larry Bartels, Democracy for Realists, Princeton University Press, 2016, ch. 6.

Data set: LINK

Stata commands: scatter incumbentpartyvotemargin tenureadjustedincomegrowth, msymbol(i) mlabel(year) mlabposition(0) mlabsize(*1) || lfit incumbentpartyvotemargin tenureadjustedincomegrowth, connect(direct) clpattern(solid) clwidth(*1.5) clcolor(black) || , scale(1.425) ysize(2.5) xsize(4) ytitle("Incumbent party vote margin", margin(0 0 0 0)) xtitle("Tenure-adjusted income growth", margin(0 0 0 2)) ylabel(-10 "-10 " 0 "0 " 20 "20%", angle(horizontal)) xlabel(-3 0 3 "3%") yline(0, lwidth(thin)) plotregion(style(none)) graphregion(margin(l+11 r+32)) legend(off)

EARNINGS BY EDUCATION ACROSS INDIVIDUALS IN THE US

Figure 2. Earnings by education across individuals in the US
Median earnings, 2016. Persons age 25 and over. Weekly earnings multiplied by 50. “k” = thousand. “13-15” = some college, no degree. “As” = Associate’s degree. “BA” = bachelor’s degree. “MA” = Master’s degree. “Prof” = professional degree. “PhD” = doctoral degree. Data source: Bureau of Labor Statistics, “Earnings and Unemployment Rates by Educational Attainment,” using Current Population Survey data.

Data set: LINK

Stata commands: scatter earnings_median_annual_2016 educationgroup, msymbol(circle) msize(*1.4) mcolor(black) connect(none) || , scale(1.425) ysize(2.5) xsize(4) ytitle("Individual earnings", margin(0 0 0 0)) xtitle("Education: schooling completed", margin(0 0 0 2)) ylabel(0 "0 " 25000 "25 " 87000 "$87k", angle(horizontal)) xlabel(1 "0-11" 2 "12" 3 "13-15" 4 "As" 5 "BA" 6 "MA" 7 "Prof" 8 "PhD") plotregion(style(none)) graphregion(margin(l+10 r+32)) legend(off)

LIFE EXPECTANCY BY EDUCATION ACROSS COUNTRIES

Figure 9. Life expectancy by education across countries
Life expectancy: years of life expectancy at birth, 2014. Data source: OECD. Education: average literacy and numeracy score on the OECD’s Survey of Adult Skills, 2013. Data source: OECD, Skills Outlook, 2013, tables A2.2a and A2.6a. The line is a linear regression line.

Data set: LINK

Stata commands: scatter lifeexpectancy_2014 literacy_overallmean_2013, mlabel(countryabbr) mlabposition(0) mlabsize(*1.25) msymbol(i) connect(none) || lfit lifeexpectancy_2014 literacy_overallmean_2013, connect(direct) clpattern(solid) clwidth(thick) clcolor(black) || , scale(1.425) ysize(2.5) xsize(4) ytitle("Life expectancy", margin(0 0 0 0)) xtitle("Education: adult literacy", margin(0 0 0 2)) ylabel(78 84, angle(horizontal)) xlabel(245 295) plotregion(style(none)) graphregion(margin(l+15 r+32)) legend(off)

SPENDING IS TOO LITTLE ON ASSISTANCE TO THE POOR

Figure 23. Spending is too little on assistance to the poor
Estimated share of US adults. Response options: too little, about right, too much. The line shows the share choosing too little. Data source: General Social Survey, sda.berkeley.edu, series natfarey.

Data set: LINK

Stata commands: scatter toolittle year, msymbol(i) connect(direct) clpattern(solid) clwidth(thick) clcolor(black) || , scale(1.425) ysize(2.5) xsize(4) ytitle("", margin(0 0 0 0)) xtitle("Year", margin(0 0 0 2)) ylabel(0 "0 " 25 "25 " 50 "50 " 75 "75 " 100 "100%", angle(horizontal)) xlabel(1970 1980 "80" 1990 "90" 2000 2010 "10") plotregion(style(none)) graphregion(margin(l+12 r+28)) legend(off)

EARTH’S AVERAGE TEMPERATURE


Figure 4. Earth’s average temperature
Difference from the 1901-2000 average. Degrees Celcius. Land and ocean. The line is a loess curve. Data source: National Centers for Environmental Information, National Oceanic and Atmospheric Administration, ncdc.noaa.gov/cag/time-series/global.

Data set: LINK

Stata commands: scatter temperatureanomaly_noaa year, msymbol(circle) msize(*.4) mcolor(gs10) connect(none) clpattern(solid) clwidth(thick) clcolor(black) || lowess temperatureanomaly_noaa year, connect(direct) clpattern(solid) clwidth(thick) clcolor(black) || , scale(1.425) ysize(2.5) xsize(4) ytitle("", margin(0 0 0 0)) xtitle("Year", margin(0 0 0 2)) ylabel(0 "0 " 1 "+1°C", angle(horizontal)) xlabel(1750 1850 1950 2018) plotregion(style(none)) graphregion(margin(l+13 r+28)) legend(off)

LIFE EXPECTANCY OVER TIME IN THE US AND OTHER RICH DEMOCRACIES

Figure 4. Life expectancy
Years of life expectancy at birth. The vertical axis doesn’t begin at zero. Data source: OECD. “Asl” is Australia; “Aus” is Austria.

Data set: LINK

Stata commands: scatter lifeexpectancy year if year>=1960 & country=="Australia", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Austria", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Belgium", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Canada", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Denmark", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Finland", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="France", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Germany", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Ireland", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Italy", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Japan", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Korea", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Netherlands", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="New Zealand", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Norway", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Portugal", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Spain", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Sweden", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="Switzerland", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="United Kingdom", msymbol(i) connect(direct) clpattern(solid) clwidth(vthin) clcolor(black) || scatter lifeexpectancy year if year>=1960 & country=="United States", msymbol(i) connect(direct) clpattern(solid) clwidth(thick) clcolor(black) || , scale(1.425) ysize(2.5) xsize(4) ytitle("", margin(0 0 0 0)) xtitle("Year", margin(0 0 0 2)) ylabel(70 79 84, angle(horizontal)) xlabel(1960 1970 "70" 1980 "80" 1990 "90" 2000 2010 "10" 2020 "20") plotregion(style(none)) graphregion(margin(l+14 r+28)) legend(off) text(78.6 2018.5 "US", placement(east) margin(0 0 0 0) justification(left) size(*.95)) text(82.7 2018.5 "Ja, Swi, Sp, It, Kor" "Nor, Asl, Fr, Swe, Ire" "Can, NZ, Nth, Aus, Fin" "Bel, Por, UK, Den, Ger", placement(east) margin(0 0 0 0) justification(left) size(*.7))

HOW DO RICH DEMOCRATIC NATIONS VARY IN HELPING PEOPLE HAVE A BALANCED LIFE?

Figure 8. Mandated paid vacation days and holidays
Per year. Legally mandated paid vacation days and paid holidays. Data source: Adewale Maye, “No Vacation Nation, Revised,” Center for Economic and Policy Research, 2019. “Asl” is Australia; “Aus” is Austria.

Data set: LINK

Stata commands: graph dot paiddaystotal_cepr2019, over(countryabbr, sort(paiddaystotal_cepr2019) descending axis(noline)) nofill scale(1.1) ysize(3.25) xsize(4) ytitle(" ", margin(0 0 0 0)) ylabel(0 19 39) yscale(noline) plotregion(style(none) margin(b=0 t=0)) graphregion(margin(l+15 r+25)) linetype(line) lines(lwidth(vthin)) legend(off) marker(1, msymbol(circle) mcolor(black) msize(1.6))