Stata command for scatter or line plots of group means with error bars.
net install segraph, from("https://raw.githubusercontent.com/MalcolmWardlaw/segraph/main/")segraph varlist [if] [in] [aweight], by(varname) [options]| Option | Description |
|---|---|
by(varname) |
Grouping variable for the x-axis (required) |
subpop(varname) |
Split series by subpopulation levels (up to 8) |
line |
Connected lines instead of scatter points |
nose |
Suppress error bars |
scale(#) |
Error bar multiplier (default: 1.96) |
ci(#) |
Confidence interval percent, 1--99 (e.g., ci(95)) |
setype(string) |
Error type: semean (default), sebinomial, or sd |
axis2 |
Plot 2nd+ variables on right y-axis |
refline(numlist) |
Vertical reference lines |
scheme() name() title() subtitle() note() legend() saving() |
Standard graph options |
xlabel() xtitle() xscale() ylabel() ytitle() yscale() |
Axis options |
graphopt(string) |
Additional twoway options passed through |
webuse nlswork, clear
* Basic scatter of means with error bars
segraph ln_wage hours, by(year)
* Line graph with 90% confidence intervals
segraph ln_wage, by(year) line ci(90)
* Subpopulations by college graduation
segraph ln_wage, by(year) subpop(collgrad)
* Dual axis with title
segraph ln_wage hours, by(year) axis2 title("Wages and Hours over Time")
* Weighted means with standard deviation bars
segraph ln_wage [aw=hours], by(year) setype(sd)Malcolm Wardlaw, University of Georgia