Examples

Six common graphs in cleanplots and in Stata’s traditional scheme s2color

Each example below, except the last, draws the same graph twice: once with scheme(cleanplots) and once with scheme(s2color), Stata’s traditional scheme. Nothing else about the commands changes. Each example loads its data from the web, so every example can be run as shown. With set scheme cleanplots, perm in place, the scheme() option is not needed.

Histogram

use "https://tdmize.github.io/data/data/addhealth4", clear
(addhealth4_dmv.dta | Add Health Wave IV | DMV Workshop)
hist vidtv, percent scheme(cleanplots)
(bin=36, start=0, width=4.6666667)
hist vidtv, percent scheme(s2color)
(bin=36, start=0, width=4.6666667)

Histogram of hours of video and television per week with the cleanplots scheme: white background, light gridlines, horizontal axis labels.

cleanplots

The same histogram in the s2color scheme.

s2color

Predictions from an ordinal logit with dashed confidence intervals

quietly ologit health orole vrole i.woman age income i.race i.educ
quietly margins, at(orole=(0(1)10))
marginsplot, recastci(rline) ciopts(lpattern(dash) color(*.5)) scheme(cleanplots) ///
    legend(order(6 "Poor" 7 "Fair" 8 "Good" 9 "Very Good" 10 "Excellent"))
Variables that uniquely identify margins: orole
marginsplot, recastci(rline) ciopts(lpattern(dash) color(*.5)) scheme(s2color) ///
    legend(order(6 "Poor" 7 "Fair" 8 "Good" 9 "Very Good" 10 "Excellent"))
Variables that uniquely identify margins: orole

Predicted probabilities of five self-rated health categories across a count of obligatory roles, with dashed confidence-interval lines, in the cleanplots scheme: each category has its own color, marker, and line pattern.

cleanplots

The same plot in the s2color scheme.

s2color

Predictions at combinations of two nominal variables

quietly logit alcB i.woman##i.parrole c.age i.race i.educ c.wages
quietly margins, at(woman=(0 1) educ=(0(1)4))
marginsplot, recast(scatter) x(educ) scheme(cleanplots)
Variables that uniquely identify margins: woman educ
marginsplot, recast(scatter) x(educ) scheme(s2color)
Variables that uniquely identify margins: woman educ

Predicted probability of drinking alcohol by education level for men and women, as points with confidence intervals, in the cleanplots scheme.

cleanplots

The same plot in the s2color scheme.

s2color

Bar chart

cleanplots uses its softer palette for the bars.

use "https://tdmize.github.io/data/data/cda_gss", clear
(cda_gss.dta |  GSS 1972-2021 CDA - Categorical Data Analysis | date created 2023)
graph bar income, over(degree) over(woman) asyvars scheme(cleanplots)
graph bar income, over(degree) over(woman) asyvars scheme(s2color)

Bar chart of mean income by degree, grouped by gender, in the cleanplots scheme: softer bar colors and a light grid.

cleanplots

The same bar chart in the s2color scheme.

s2color

Residual and influence plot

use "https://tdmize.github.io/data/data/pew16", clear
(pew16_dmv.dta | Pew 2016 Pre-Election Data | DMV Workshop)
quietly logit trump i.woman c.age ib4.educ i.race i.polparty3 ///
              i.religB c.income ib3.region
gen index = _n
predict residstd, rs
predict influence, dbeta
twoway scatter residstd index [w=influence], scheme(cleanplots)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
twoway scatter residstd index [w=influence], scheme(s2color)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)

Scatter plot of standardized residuals against observation number with markers sized by influence, in the cleanplots scheme.

cleanplots

The same plot in the s2color scheme.

s2color

Lowess plot

use "https://tdmize.github.io/data/data/scireview3", clear
(Biochemist data - updated for CDA Stata guide)
sort phd
lowess jobimp phd, scheme(cleanplots)
lowess jobimp phd, scheme(s2color)

Lowess smoother of job importance against PhD prestige with the scatter of points, in the cleanplots scheme.

cleanplots

The same lowess plot in the s2color scheme.

s2color

All ten colors

A scatter plot with ten groups and the matching bar chart show the full palette, with the darker and lighter colors alternating.

use "https://tdmize.github.io/data/data/cda_gss", clear
(cda_gss.dta |  GSS 1972-2021 CDA - Categorical Data Analysis | date created 2023)
keep if year == 2016
(65,979 observations deleted)
twoway scatter income occprest if isco88cat == 1, msize(medium) jitter(10) || ///
       scatter income occprest if isco88cat == 2, msize(medium) jitter(10) || ///
       scatter income occprest if isco88cat == 3, msize(medium) jitter(10) || ///
       scatter income occprest if isco88cat == 4, msize(medium) jitter(10) || ///
       scatter income occprest if isco88cat == 5, msize(medium) jitter(10) || ///
       scatter income occprest if isco88cat == 7, msize(medium) jitter(10) || ///
       scatter income occprest if isco88cat == 8, msize(medium) jitter(10) || ///
       scatter income occprest if isco88cat == 9, msize(medium) jitter(10) || ///
       scatter income occprest if isco88cat == 10, msize(medium) jitter(10) || ///
       scatter income occprest if isco88cat == 11, msize(medium) jitter(10) || ///
       , scheme(cleanplots) ///
       legend(order(1 "higher controllers" 2 "lo controllers" 3 "routine nonmanual" ///
              4 "sempl with emp" 5 "sempl without empl" 6 "manual supervisor" ///
              7 "skilled manual" 8 "semi-unskilld manual" 9 "farm labor" ///
              10 "selfempl farm"))
graph bar income, over(isco88cat) asyvars scheme(cleanplots) ///
    title("Average income by occupation")

Scatter plot of income against occupational prestige with ten occupation groups in the ten cleanplots colors and marker symbols.

Scatter plot

Bar chart of average income for ten occupation groups in the softer cleanplots bar colors.

Bar chart
Back to top