-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathscheme_test.do
213 lines (145 loc) · 4.92 KB
/
scheme_test.do
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
****************************
****************************
*** ***
*** schemepack v1.4 ***
*** ***
*** Asjad Naqvi ***
*** ***
*** The Stata Guide ***
*** on Medium ***
*** ***
*** 08 Nov 2022 ***
*** ***
****************************
****************************
* https://github.com/asjadnaqvi/stata-schemepack
* https://medium.com/the-stata-guide
// report errors here:
* https://github.com/asjadnaqvi/stata-schemepack/issues
clear
// See github page to check if there are version differences between SSC and GitHub
// install from ssc
*ssc install schemepack, replace
// OR install from GitHub
*net install schemepack, from("https://raw.githubusercontent.com/asjadnaqvi/stata-schemepack/main/installation/") replace
// read the data
use "https://github.com/asjadnaqvi/Stata-schemes/blob/main/scheme_test.dta?raw=true", clear
// you either type:
* set scheme white_tableau
* set scheme black_tableau
* set scheme gg_tableau
// or permanently set the theme
* set scheme white_tableau, perm
// or set it in a graph directly
* twoway (scatter var2 date if group==1), scheme(white_tableau)
// Feel free to try these on your own datasets and please report errors if any
set scheme white_tableau
*****************************************
*********** TEST GRAPHS BELOW ***********
*****************************************
// note that some schemes might only have only 6 or 8 color. Therefore the cycle repeats once the last defined
// color of a scheme is reached.
*** Scatter plot
twoway ///
(scatter var2 date if group==1) ///
(scatter var2 date if group==2) ///
(scatter var2 date if group==3) ///
(scatter var2 date if group==4) ///
(scatter var2 date if group==5) ///
(scatter var2 date if group==6) ///
(scatter var2 date if group==7) ///
(scatter var2 date if group==8) ///
(scatter var2 date if group==9) ///
(scatter var2 date if group==10) ///
(scatter var2 date if group==11) ///
(scatter var2 date if group==12) ///
, ///
legend(order(1 "group1" 2 "group2" 3 "group3" 4 "group4" 5 "group5" 6 "group6" 7 "group7" 8 "group8" 9 "group9" 10 "group10" 11 "group11" 12 "group12")) ///
title("Scatter plot") ///
note("By the Stata Guide")
*** Line graph
twoway ///
(line var2 date if group==1) ///
(line var2 date if group==2) ///
(line var2 date if group==3) ///
(line var2 date if group==4) ///
(line var2 date if group==5) ///
(line var2 date if group==6) ///
(line var2 date if group==7) ///
(line var2 date if group==8) ///
(line var2 date if group==9) ///
(line var2 date if group==10) ///
(line var2 date if group==11) ///
(line var2 date if group==12) ///
, ///
legend(order(1 "group1" 2 "group2" 3 "group3" 4 "group4" 5 "group5" 6 "group6" 7 "group7" 8 "group8" 9 "group9" 10 "group10" 11 "group11" 12 "group12")) ///
title("Line plot") ///
note("The Stata Guide", size(vsmall))
*** Pie chart
graph pie var2 if group <= 10, ///
over(group) plabel(_all percent, format(%9.2f)) ///
line(lcolor(black) lwidth(vvthin)) /// // outline colors have to be manually added
title("Pie plot") ///
note("The Stata Guide", size(vsmall))
*** Box plot
graph box ///
var* ///
, ///
title("Box plot") ///
note("The Stata Guide", size(vsmall))
*** Histogram
histogram var4, percent ///
title("Histogram") ///
note("The Stata Guide", size(vsmall))
*** Bar graph
graph bar ///
var* ///
, ///
blabel(bar, format(%9.2f)) ///
title("Bar graph") ///
note("The Stata Guide", size(vsmall))
*** Horizontal bar graph
graph hbar (mean) ///
var* ///
if group <= 6, ///
over(group) ///
percentages stack ///
legend(order(1 "Var 1" 2 "Var 2" 3 "Var 3" 4 "Var 4" 5 "Var 5" 6 "Var 6")) ///
title("Bar graph") ///
note("The Stata Guide", size(vsmall))
*** Confidence bands
twoway ///
(lpolyci var1 var9, fcolor(%80)) ///
(lpolyci var2 var9, fcolor(%80)) ///
(lpolyci var3 var9, fcolor(%80)) ///
, ///
title("Confidence Interval") ///
note("The Stata Guide", size(vsmall))
*** Range graphs
twoway ///
(rcapsym var2 var3 date if group==1, sort) ///
(rcapsym var2 var3 date if group==2, sort) ///
, ///
title("Range plots") ///
note("The Stata Guide", size(vsmall))
*** Area graphs
twoway ///
(area den1d den1x, fcolor(%50)) ///
(area gen2d gen2x, fcolor(%50)) ///
(area gen3d gen3x, fcolor(%50)), ///
title("Density plots") ///
note("The Stata Guide", size(vsmall))
*** Scatter labels
twoway ///
(scatter var2 var1, mlabel(group)) ///
if date==22320 ///
, ///
title("Confidence Interval") ///
note("The Stata Guide", size(vsmall))
*** By graphs
twoway ///
(scatter var2 var1) ///
if group <= 12, ///
by(group, yrescale xrescale) ///
by(, title("By graphs") note("The Stata Guide", size(vsmall)))
//// ******* END OF FILE ******* \\\\