Data @ Reed

Scatterplots

Scatterplots provide a quick visual for examining the relationship between two continuous variables. This example will get you started with scatterplots.

Using the wide-format blood pressure data, I'd like to compare blood pressure for patients before and after [some physical activity]. (Note: this is a ficticious dataset)

First load the data 

. sysuse bpwide

Initial graph: blood pressure before and after

. graph twoway scatter bp_before bp_after

Note: this can also be written in simpler terms

. scatter bp_before bp_after

 It might also be interesting to create graphs based on sex or age groups:

. scatter bp_before bp_after, by(agegrp)
. scatter bp_before bp_after, by(sex)

Note that Stata will allow you to make questionable data decisions, such as creating scatterplots of variables that are not continuous. Using the same dataset, try the following; consider what the graphs show well, and where they fall short.

. scatter bp_before agegrp
. scatter sex agegrp

Additional resources

Like many commands in Stata, there are a wealth of options for modifying the resulting visuals; for details on myriad possibilities, see the graph twoway scatter help documentation. For a general introduction to graphics in Stata, see this guide from UCLA.