-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtwowayscatter.ado
More file actions
68 lines (58 loc) · 1.5 KB
/
twowayscatter.ado
File metadata and controls
68 lines (58 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
program twowayscatter , rclass
version 14
syntax varlist(min=2 max=3) ///
[ , color1(string) color2(string) conditions(string) ///
debug file(string) lfit ///
type1(string) type2(string) ncorr singleaxis omit twopts(string)]
if "`omit'" == "omit"{
di "Graph skipped: `file'"
exit
}
if "`type1'" == ""{
local type1 "scatter"
}
if "`type2'" == ""{
local type2 "scatter"
}
local k = 0
foreach var in `varlist'{
local `k++'
}
token `varlist'
if "`lfit'" == "lfit"{
local linegraph "(lfit `1' `2')"
}
if "`ncorr'" != "ncorr" {
qui corr `1' `2' `conditions'
local corr : di %5.3g r(rho)
local corrs "subtitle(correlation `corr')"
}
if "`singleaxis'" != "singleaxis"{
local yaxisval "yaxis(2)"
}
if `k' == 3{
if "`color1'" != "" & "`color2'" != ""{
twoway (`type1' `1' `3' `conditions' , mcolor("`color1'")) ///
(`type2' `2' `3' `conditions' , `yaxisval' mcolor("`color2'")) `linegraph' , ///
graphregion(color(white)) `corrs' `twopts'
}
else {
twoway (`type1' `1' `3' `conditions') ///
(`type2' `2' `3' `conditions' , `yaxisval') `linegraph' , ///
graphregion(color(white)) `corrs' `twopts'
}
}
else if `k' == 2{
if "`color1'" != "" {
twoway (`type1' `1' `2' `conditions' , mcolor("`color1'")) `linegraph' , ///
graphregion(color(white)) `corrs' `twopts'
}
else {
twoway (`type1' `1' `2' `conditions') `linegraph' , ///
graphregion(color(white)) `corrs' `twopts'
}
}
if "`file'" != ""{
graph2 , file("`file'") `debug'
}
end