Skip to Main Content

NJC Stata Plots | Stata FAQ

This page presents examples of graphics programs written by Nicholas J. Cox
(Durham University).  You can obtain these programs by typing, search command_name,
into the Stata command line and following the instructions (see
How can I use the search command to search for programs and get additional
help?
for more information about using search).  This page is not an exhaustive
list of all of the graphics commands written by Nick Cox but merely a collection of the
ones that we use most frequently.  The command ssc install njc_stuff will download
two help files listing all programs written by Nick Cox, including his graph commands.

This page contains only the commands and the plots themselves, there is no further explanation.
We envision that users will look through the plots and when they find one that appears
to do what they want, they will download the program and carefully read the help files.

Most of these examples use the hsb2 dataset which can be downloaded from
within Stata using the following command:

use https://stats.idre.ucla.edu/stat/data/hsb2, clear

Note: Most of the graphs were produced using the scheme lean1.  Whenever a different
scheme is used, it is given in the command.

asciiplot– graph ASCII character set in current graph font

asciiplot
Image asciiplot1

anovaplot– plot cell means following anova

anova write female prog female*prog
anovaplot prog female
Image anovaplot1
anovaplot prog female, scatter(msym(i))
Image anovaplot2

beamplot — horizontal dotplots using beams

beamplot write
Image beamplot1
beamplotplot write, over(female)
Image beamplot2

binsm — bin smoothing and summary on scatter plots

binsm write read, width(5) scatter(jitter(2))
Image binsm1

catplot — plots of categorical data

catplot prog race
Image catplot1
catplot prog race, by(female)
Image catplot2

ciplot — plots of confidence intervals

ciplot write science, by(female)
Image ciplot1

corrtable — correlation matrix as graphical table

corrtable read write math science
Image corrtable1

cpyxplot — twoway plots for each y vs each x

cpyxplot write \ read  math science
Image cpyxplot1

diagsm — diagonal smoothing

diagsm write math
Image diagsm1

distplot — distribution function plots

distplot write
Image distplot1
distplot write, over(female)
Image distplot3

doublesm — double smoothing

doublesm write math
Image doublesm1

dpplot — density probability plots

dpplot write
Image dpplot1

eqprhistogram — equal probability histograms

eqprhistogram write, mean
Image eqprhistogram1

fractileplot — smoothing with distribution function predictors

fractileplot write read math science socst
Image fractileplot1

indexplot — index plots following estimation

regress write read
indexplot, show(cooksd) hi(3)
Image indexplot1
indexplot, show(rstandard) base(0)
Image indexplot2

kaplansky — graph examples of distributions of varying kurtosis

kaplansky
Image kaplansky1

mlowess — lowess smoothing with multiple predictors

mlowess write read math science socst
Image mlowess1

mrunning — running line smoother (multivariable version)

mrunning write read math
Image running1

ovfplot

regress write read
ovfplot
Image ovfplot1
regress write read female
ovfplot, by(female)
Image ovfplot2

pairplot — plots of paired observations

pairplot write science in 1/30
Image pairplot1
pairplot write science in 1/30, diff
Image pairplot2

parplot — parallel coordinates plots

parplot female write science
Image parplot1

pdplot — Pareto dot plots

pdplot prog
Image pdplot1

polarsm — polar smoothing

polarsm write read, over(female) by(female)
Image polarsm1

ppplot — P-P plots

ppplot connected write, by(female) ref(0)
Image ppplot1
ppplot connected write math
Image ppplot2

qplot — quantile plots

qplot write
Image qplot1

rcspline — restricted cubic spline smoothing

rcspline write read
Image rcspline1

rdplot

regress write read
rdplot, g(3)
Image rdplot1

regplot

regress write read
regplot
Image regplot1
generate write2 = write^2
regress math write write2
regplot
Image regplot2
regress write read female
regplot, by(female) scheme(s2mono)
Image regplot3

rhetplot

regress write read
rhetplot, by(prog female)
Image rhetplot1

running — symmetric nearest neighbor smoothing

running write read, scatter(jitter(2))
Image running1

rvfplot2

regress write read female
rvfplot2, rstandard yline(0)
Image rvfplot2-1

rvpplot2

regress write read female
rvpplot2 read, rstandard yline(0)
Image rvpplot2-1

skewplot — skewness plots

skewplot math
Image skewplot1

slideplot — sliding bar plots

slideplot bar female, pos(1) neg(0) by(prog)
Image slideplot1

spineplot — spine plots for two-way categorical data

spineplot ses female, bar1(color(gs14)) bar2(color(gs10)) bar3(color(gs6))
Image spineplot1
spineplot race ses
Image spineplot2

stemplot — stem-and-leaf plots

stemplot write
Image stemplot1
stemplot write, d(2) by(female) back scheme(s2mono)
Image stemplot2

stripplot — strip plots

generate pipe = "|"
stripplot write, over(prog) mlabel(pipe) mlabpos(0) msymbol(i)
Image stripplot1

tableplot — graphical display in two-way table format

use https://stats.idre.ucla.edu/stat/stata/notes/lahigh, clear
egen mabs = mean(daysabs), by(school gender)
tableplot rbar mabs school gender
Image tableplot1

tabplot — two-way table shown as table of bars

use https://stats.idre.ucla.edu/stat/data/hsb2, clear
tabplot ses female, showval percent(female)
Image tabplot1