暨南大学各个专业男女生比例

暨南大学各个专业男女生比例

即兴绘制,今天的图展示了2015级到2017级,也就是现在在学校的3个年级各个专业的女生数量和女生比例。

数据源

这幅图使用的数据依然是我从暨大体育爬到的全校大部分同学的身份信息数据。为了方便大家使用,我还是决定把这个数据分享出来:暨南大学大陆学生生源地信息表.dta。因为这份数据里面涉及同学们的身份信息,请朋友们不要使用这份数据干不好的事情。

整理数据

为了绘制这幅图,我们首先需要将数据整理成每年每个专业的女生比例数据。整理代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use 暨南大学大陆学生生源地信息表, clear
keep 姓名 性别 行政班级
gen 届 = substr(行政班级, 1, 4)
destring 届, force replace
replace 行政班级 = ustrregexs(0) if ustrregexm(行政班级, "[\u4e00-\u9fa5]+")
contract 性别 行政班级 届
gsort 届 行政班级 性别
order 届 行政班级 性别
gen ratio = _freq[_n]/(_freq[_n] + _freq[_n+1]) if mod(_n, 2) == 1
ren _freq girlnum
gen boynum = girlnum[_n+1] if mod(_n, 2) == 1
drop if mod(_n, 2) == 0
compress
drop 性别
egen totalnum = rowtotal(girlnum boynum)
save 暨南大学2014-2017级各个专业的女生比例, replace

整理结果:

在进行数目统计的时候,contract命令是一个非常好用的命令。

Stata绘制气泡图

首先可以用Stata绘制一个气泡图,绘制代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
use 暨南大学2014-2017级各个专业的女生比例, clear
tw ///
sc ratio girlnum [fw = totalnum] if 届 == 2014, mfcolor(十样锦) mlcolor(十样锦) || ///
sc ratio girlnum [fw = totalnum] if 届 == 2015, mfcolor(库金) mlcolor(库金) || ///
sc ratio girlnum [fw = totalnum] if 届 == 2016, mfcolor(桔黄) mlcolor(桔黄) || ///
sc ratio girlnum [fw = totalnum] if 届 == 2017, mfcolor(孔雀蓝) mlcolor(孔雀蓝) ||, ///
sch(plottig) ///
xla(0(10)120) ///
xti("女生数量") ///
yti("女生比例") ///
leg(order(1 "2014级" 2 "2015级" 3 "2016级" 4 "2017级") pos(6) rows(1)) ///
ti("暨南大学2014-2017级各个专业的女生比例和女生数量")
gre 暨南大学2014-2017级各个专业的女生比例和女生数量

这里面使用的颜色就是我之前博客介绍的我自己编写的颜色:cncm&jpncm命令——帮助选色配色

不过这个图存在很大的问题,就是因为这是一副静态的图,如果我把每个专业的名字都加上去就会使得标签过于密集,但是要是没有标签就会损失很多信息。所以下面用ECharts绘制这幅图。

ECharts绘制气泡图

稍微对比就可以发现每年我们金融学的女生比例和女生数量变化都很大啊!
同样使用fw命令即可很容易的绘制出上面的气泡图,这个图的模板是借鉴这位大佬的:各学院男女占比图 By 凹可卡 on 1 年前

下面的代码即可绘制:

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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
use 暨南大学2014-2017级各个专业的女生比例, clear
replace ratio = 0 if missing(ratio)
jscopy
fw, s
lib, b sch(roma)
fw "var data = ["
fw " ["
cap restore
preserve
keep if 届 == 2015
forval i = 1/`=_N'{
fw `"[`=girlnum[`i']',`=ratio[`i']',`=totalnum[`i']', "`=行政班级[`i']'", "`=届[`i']'"],"'
}
fw " ],["
cap restore
preserve
keep if 届 == 2016
forval i = 1/`=_N'{
fw `"[`=girlnum[`i']',`=ratio[`i']',`=totalnum[`i']', "`=行政班级[`i']'", "`=届[`i']'"],"'
}
fw " ],["
cap restore
preserve
keep if 届 == 2017
forval i = 1/`=_N'{
fw `"[`=girlnum[`i']',`=ratio[`i']',`=totalnum[`i']', "`=行政班级[`i']'", "`=届[`i']'"],"'
}
fw " ]];"
fw `"isShowCollege2 = 0"'
fw `"isShowCollege3 = 0"'
fw `"isShowCollege4 = 0"'
fw `"option = {"'
fw `" tooltip: {"'
fw `" trigger: "item","'
fw `" formatter: function(params) {"'
fw `" return params.value[3] + ":" + parseInt(params.value[1] * 1000) / 10 + "%""'
fw `" }"'
fw `" },"'
fw `" toolbox: {"'
fw `" left: "160","'
fw `" feature: {"'
fw `" saveAsImage: {"'
fw `" show: true"'
fw `" },"'
fw `" myshowcollege2: {"'
fw `" show: true,"'
fw `" icon: "image://http://omudx2uw8.bkt.clouddn.com/ring0.jpg","'
fw `" title: "显示2015级专业名称","'
fw `" onclick: function() {"'
fw `" // alert("好")"'
fw `" if (isShowCollege2 == 0) {"'
fw `" myChart.setOption({"'
fw `" series: [{"'
fw `" label: {"'
fw `" normal: {"'
fw `" formatter: function(param) {"'
fw `" return param.data[3];"'
fw `" }"'
fw `" }"'
fw `" }"'
fw `" }]"'
fw `" })"'
fw `" isShowCollege2 = 1"'
fw `" } else {"'
fw `" myChart.setOption({"'
fw `" series: [{"'
fw `" label: {"'
fw `" normal: {"'
fw `" formatter: """'
fw `" }"'
fw `" }"'
fw `" }]"'
fw `" })"'
fw `" isShowCollege2 = 0"'
fw `" }"'
fw `" }"'
fw `" },"'
fw `" myshowcollege3: {"'
fw `" show: true,"'
fw `" icon: "image://http://omudx2uw8.bkt.clouddn.com/ring0.jpg","'
fw `" title: "显示2016级专业名称","'
fw `" onclick: function() {"'
fw `" // alert("好")"'
fw `" if (isShowCollege3 == 0) {"'
fw `" myChart.setOption({"'
fw `" series: [{}, {"'
fw `" label: {"'
fw `" normal: {"'
fw `" formatter: function(param) {"'
fw `" return param.data[3];"'
fw `" }"'
fw `" }"'
fw `" }"'
fw `" }]"'
fw `" })"'
fw `" isShowCollege3 = 1"'
fw `" } else {"'
fw `" myChart.setOption({"'
fw `" series: [{}, {"'
fw `" label: {"'
fw `" normal: {"'
fw `" formatter: """'
fw `" }"'
fw `" }"'
fw `" }]"'
fw `" })"'
fw `" isShowCollege3 = 0"'
fw `" }"'
fw `" }"'
fw `" },"'
fw `" myshowcollege4: {"'
fw `" show: true,"'
fw `" icon: "image://http://omudx2uw8.bkt.clouddn.com/ring0.jpg","'
fw `" title: "显示2017级专业名称","'
fw `" onclick: function() {"'
fw `" // alert("好")"'
fw `" if (isShowCollege4 == 0) {"'
fw `" myChart.setOption({"'
fw `" series: [{}, {}, {"'
fw `" label: {"'
fw `" normal: {"'
fw `" formatter: function(param) {"'
fw `" return param.data[3];"'
fw `" }"'
fw `" }"'
fw `" }"'
fw `" }]"'
fw `" })"'
fw `" isShowCollege4 = 1"'
fw `" } else {"'
fw `" myChart.setOption({"'
fw `" series: [{}, {}, {"'
fw `" label: {"'
fw `" normal: {"'
fw `" formatter: """'
fw `" }"'
fw `" }"'
fw `" }]"'
fw `" })"'
fw `" isShowCollege4 = 0"'
fw `" }"'
fw `" }"'
fw `" }"'
fw `" }"'
fw `" },"'
fw `" backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [{"'
fw `" offset: 0,"'
fw `" color: '#f7f8fa'"'
fw `" }, {"'
fw `" offset: 1,"'
fw `" color: '#cdd0d5'"'
fw `" }]),"'
fw `" title:{"'
fw `" text: "暨南大学各专业女生比例","'
fw `" left: "center""'
fw `" },"'
fw `" legend: {"'
fw `" right: 10,"'
fw `" data: ['2015', '2016', '2017']"'
fw `" },"'
fw `" xAxis: {"'
fw `" name: "女生数量","'
fw `" splitLine: {"'
fw `" lineStyle: {"'
fw `" type: 'dashed'"'
fw `" }"'
fw `" }"'
fw `" },"'
fw `" yAxis: {"'
fw `" name: "女生占比","'
fw `" splitLine: {"'
fw `" lineStyle: {"'
fw `" type: 'dashed'"'
fw `" }"'
fw `" },"'
fw `" scale: true"'
fw `" },"'
fw `" series: [{"'
fw `" name: '2015',"'
fw `" data: data[0],"'
fw `" type: 'scatter',"'
fw `" symbolSize: function(data) {"'
fw `" return Math.sqrt(data[2]) * 2;"'
fw `" },"'
fw `" label: {"'
fw `" normal: {"'
fw `" show: true,"'
fw `" formatter: "","'
fw `" position: 'top',"'
fw `" },"'
fw `" emphasis: {"'
fw `" show: true,"'
fw `" formatter: function(param) {"'
fw `" return param.data[3];"'
fw `" },"'
fw `" position: 'top'"'
fw `" }"'
fw `" },"'
fw `" itemStyle: {"'
fw `" normal: {"'
fw `" shadowBlur: 10,"'
fw `" shadowColor: 'rgba(120, 36, 50, 0.5)',"'
fw `" shadowOffsetY: 5,"'
fw `" color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{"'
fw `" offset: 0,"'
fw `" color: 'rgb(251, 118, 123)'"'
fw `" }, {"'
fw `" offset: 1,"'
fw `" color: 'rgb(204, 46, 72)'"'
fw `" }])"'
fw `" }"'
fw `" }"'
fw `" }, {"'
fw `" name: '2016',"'
fw `" data: data[1],"'
fw `" type: 'scatter',"'
fw `" symbolSize: function(data) {"'
fw `" return Math.sqrt(data[2]) * 2;"'
fw `" },"'
fw `" label: {"'
fw `" normal: {"'
fw `" show: true,"'
fw `" formatter: "","'
fw `" position: 'top'"'
fw `" },"'
fw `" emphasis: {"'
fw `" show: true,"'
fw `" formatter: function(param) {"'
fw `" return param.data[3];"'
fw `" },"'
fw `" position: 'top'"'
fw `" }"'
fw `" },"'
fw `" itemStyle: {"'
fw `" normal: {"'
fw `" shadowBlur: 10,"'
fw `" shadowColor: 'rgba(25, 100, 150, 0.5)',"'
fw `" shadowOffsetY: 5,"'
fw `" color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{"'
fw `" offset: 0,"'
fw `" color: 'rgb(129, 227, 238)'"'
fw `" }, {"'
fw `" offset: 1,"'
fw `" color: 'rgb(25, 183, 207)'"'
fw `" }])"'
fw `" }"'
fw `" }"'
fw `" }, {"'
fw `" name: '2017',"'
fw `" data: data[2],"'
fw `" type: 'scatter',"'
fw `" symbolSize: function(data) {"'
fw `" return Math.sqrt(data[2]) * 2;"'
fw `" },"'
fw `" label: {"'
fw `" normal: {"'
fw `" show: true,"'
fw `" formatter: "","'
fw `" position: 'top'"'
fw `" },"'
fw `" emphasis: {"'
fw `" show: true,"'
fw `" formatter: function(param) {"'
fw `" return param.data[3];"'
fw `" },"'
fw `" position: 'top'"'
fw `" }"'
fw `" },"'
fw `" itemStyle: {"'
fw `" normal: {"'
fw `" shadowBlur: 10,"'
fw `" shadowColor: 'rgba(25, 100, 150, 0.5)',"'
fw `" shadowOffsetY: 5,"'
fw `" color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{"'
fw `" offset: 0,"'
fw `" color: 'rgb(52, 128, 256)'"'
fw `" }, {"'
fw `" offset: 1,"'
fw `" color: 'rgb(52, 52, 207)'"'
fw `" }])"'
fw `" }"'
fw `" }"'
fw `" }]"'
fw `"};"'
fw, e t

# Stata

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×