Graphics

Creating simple graphs to visualize your data

Stata produces publication-quality graphs that can be modified to fit publishers' formats, and schemes (templates) are available for many journals to automate this process.

This page gives a few examples of graphs that you might want to create, but it by no means does justice to the broad capability of Stata graphics. In addition to the Stata Graphics PDF manual and the online help, other sources of information include A Visual Guide to Stata Graphics by Michael Mitchell (available from Stata Press), the drop-down Graphics menu in the Windows version of Stata, and a couple of online learning aids:

Each of the commands below creates an example of a commonly used graph. Use the Tanzania 1999 facility data file, then run the following commands to see the examples. 


clear
use "q:\utilities\statatut\exampfac.dta"

/* Create Government vs Non-govt authority */

gen govt= .
replace govt= 1 if authorit == 1
replace govt= 0 if authorit > 1 & !missing(authorit)
label define g 0 "Non-govt" 1 "Govt"
label value govt g

/* Count FP staff-hours/week at each facility */

gen fphrs= 0
foreach v of varlist fphour* {
   replace fphrs= fphrs + `v'  if !missing(`v')
}

/* Count FP methods available at each facility */

gen methods= 0
foreach v of varlist pill-natural {
   replace methods= methods + 1  if `v' == 1
}

/* Histogram of number of methods with normal curve superimposed */

histogram methods, normal

/* Box plot of methods by whether govt or non-govt facility */

graph box methods, by(govt)

/* Scatter plot of FP hours by number of methods */

scatter fphrs methods

/* Add a linear regression line to the scatter plot */

twoway (scatter fphrs methods) (lfit fphrs methods)




Another topic?


Wink Plone Theme by Quintagroup © 2013.

Personal tools
This is themeComment for Wink theme