Stata Technical Bulletin
STB-58
graphitions are any of the standard graphics options except for by. In addition to the usual function of yline, turnip allows
users to specify special values; specifically, mean or median. If either of these is specified, the corresponding value is
added to ylabel so the value is displayed on the у-axis. Note that the default ж-axis label ranges between plus and minus
twice the maximum number of observations in an interval, while the default у-axis label adds 25% of the range above and
below the maximum and minimum values of the variable.
Examples
Issuing the command
. turnip mpg
gives the output for the mpg variable in Stata’s auto data
# of observations per turnip row is the frequency below:
≡pg I |
Freq. |
Percent |
Cum. |
— | |||
11.57101 I |
2 |
2.70 |
2.70 |
13.88521 I |
8 |
10.81 |
13.51 |
16.19941 I |
8 |
10.81 |
24.32 |
18.51361 I |
17 |
22.97 |
47.30 |
20.82781 I |
8 |
10.81 |
58.11 |
23.14201 I |
12 |
16.22 |
74.32 |
25.45621 I |
8 |
10.81 |
85.14 |
27.77042 I |
3 |
4.05 |
89.19 |
30.08462 I |
4 |
5.41 |
94.59 |
34.71302 I |
3 |
4.05 |
98.65 |
41.65562 I |
1 |
1.35 |
100.00 |
— | |||
Total I |
74 |
100.00 |
options: xlabel(-16 16) ylabel(9 45 )
resolution: 2.314201283894056
and the graph in Figure 1; see below.
We can produce a similar graph with greater resolution and with a horizontal line at the median of mpg by
. turnip mpg, res(1.5) yline(median)
# of observations per turnip row is the frequency below:
mpg I Freq. Percent Cum.
------------+----------------------------------- | |||
12 I |
2 |
2.70 |
2.70 |
13.5 I |
6 |
8.11 |
10.81 |
15 I |
2 |
2.70 |
13.51 |
16.5 I |
8 |
10.81 |
24.32 |
18 I |
9 |
12.16 |
36.49 |
19.5 I |
11 |
14.86 |
51.35 |
21 I |
5 |
6.76 |
58.11 |
22.5 I |
8 |
10.81 |
68.92 |
24 I |
4 |
5.41 |
74.32 |
25.5 I |
8 |
10.81 |
85.14 |
28.5 I |
4 |
5.41 |
90.54 |
30 I |
2 |
2.70 |
93.24 |
31.5 I |
1 |
1.35 |
94.59 |
34.5 I |
3 |
4.05 |
98.65 |
40.5 I |
1 |
1.35 |
100.00 |
Total I 74 100.00
options: yline(20) xlabel(-10 10) ylabel( 20 9 43 )
resolution: 1.5
yline: 20 (median)
which gives the graph in Figure 2.
(Continued on next page)