Introduction
Sometimes, you might want graphics such as histograms to contain x lines. In this blog entry, we’ll show you how to add x lines to graphics using simple code in Stata.
Create Data
First, we’ll create mock data, then we’ll show you how to clone a variable both generally and conditionally. Let’s assume we’re measuring IQ for 1,000 subjects.
set obs 1000
gen subj = _n
drawnorm iq_a, mean(100) sd(10)
gen iq = round(iq_a)
drop iq_a
label variable iq "IQ"
list in 1/30
Creating a Base Graphic
Let’s create a histogram of IQ:
hist iq, freq scheme(s1color)
Now let’s say we already know that the standard deviation is 10, and we went to indicate the boundaries of each standard deviation on the histogram. Try:
hist iq, xline(70 80 90 110 120 130) freq scheme(s1color)
And you get:
BridgeText provides statistical testing, analysis, coding, and interpretation services.