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].

First load the data: 

. sysuse bpwide

Create an initial graph with blood pressure before and after:

. graph twoway scatter bp_before bp_after

You can rewrite this 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

Within Stata there are a wealth of options for visualizing data and modifying graphs. For details on the different possibilities for scatterplots, see the graph twoway scatter help documentation. For a general introduction to graphics in Stata, see this guide from UCLA.