楼主: 匿名
11357 13

[Stata] Stata基础操作:绘图(六)人口金字塔及脸谱图 [推广有奖]

匿名网友
楼主
匿名网友  发表于 2015-7-13 10:59:22 |坛友微信交流群|倒序 |AI写论文
相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

Stata 12 Graphics

Dawn Koffman

Office of  Population Research  

Princeton University


人口金字塔条形图绘制

人口金字塔条形图绘制.png

  1. sysuse pop2000, clear
  2. replace maletotal = -maletotal
  3. #delimit ;
  4. twoway bar maletotal agegrp, horizontal ||
  5. bar femtotal agegrp, horizontal
  6. title("US Male and Female Population by Age, Year 2000")
  7. note("Source: US Census Bureau, Census 2000, Tables 1, 2 and 3", span);
  8. #delimit cr
复制代码
人口金字塔(含坐标轴标签):

Population Pyramid Axis Labels.png

  1. sysuse pop2000, clear
  2. replace maletotal = -maletotal
  3. replace maletotal = maletotal / 1000000
  4. replace femtotal = femtotal / 1000000
  5. #delimit ;
  6. twoway bar maletotal agegrp, horizontal ||
  7. bar femtotal agegrp, horizontal
  8. title("US Male and Female Population by Age, Year 2000")
  9. note("Source: US Census Bureau, Census 2000, Tables 1, 2 and 3", span)
  10. xtitle("Population in Millions") ytitle("Age Group Number")
  11. xlabel( -12 "12" -10 "10" -8 "8" -6 "6" -4 "4" 4(2)12)
  12. ylabel(1(1)17, angle(0))
  13. legend(order(1 "Male" 2 "Female"));
  14. #delimit cr
复制代码
人口金字塔(年龄分组标签)

Population Pyramid Age Group Labels.png

  1. sysuse pop2000, clear
  2. replace maletotal = -maletotal
  3. replace maletotal = maletotal / 1000000
  4. replace femtotal = femtotal / 1000000
  5. gen zero = 0
  6. #delimit ;
  7. twoway bar maletotal agegrp, horizontal bfc(gs7) blc(gs7) ||
  8. bar femtotal agegrp, horizontal bfc(gs11) blc(gs11) ||
  9. scatter agegrp zero, mlabel(agegrp) mlabcolor(black) msymbol(none)
  10. title("US Male and Female Population by Age, Year 2000")
  11. note("Source: US Census Bureau, Census 2000, Tables 1, 2 and 3", span)
  12. xtitle("Population in Millions") ytitle("Age Group Number")
  13. ytitle("") yscale(noline) ylabel(none)
  14. xlabel( -12 "12" -10 "10" -8 "8" -6 "6" -4 "4" 4(2)12)
  15. legend(off) text(15 -8 "Male") text(15 8 "Female");
  16. #delimit cr
复制代码

注:关于人口金字塔的绘制可参阅   演示教程命令集及Pyramid命令修改


/*Chernoff 脸谱图*/
  1. * Chernoff faces
  2. * Few cases, each face is a row case.

  3. use "http://www.princeton.edu/~otorres/chernoff.dta", clear
  4. *ssc install chernoff    //chernoff移至gr0038下
  5. findit gr0038    //安装
  6. chernoff, hdark(gdppc) bdens(trade) nose(unemp) mcurv(polity2) order(gdppc) ilabel(country)
复制代码

脸谱图.png

/*圆环图*/
  1. // Circle using function
  2. #delimit ;
  3. twoway (function y = sqrt(1 -(x)^2),
  4. range(-1 1) lwidth(thick) lcolor(red))
  5. (function y = -sqrt(1 - (x)^2),
  6. range(-1 1) lwidth(thick) lcolor(red)), aspect(1);
复制代码

circle.png



前言.PNG


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Stata基础 Stata 基础操作 tata 脸谱图 University horizontal 金字塔 Office 坐标轴

已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
xddlovejiao1314 + 100 + 100 + 5 + 5 + 5 精彩帖子

总评分: 经验 + 100  论坛币 + 100  学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

本帖被以下文库推荐

沙发
xddlovejiao1314 学生认证  发表于 2015-7-13 12:02:20 |只看作者 |坛友微信交流群
好贴,谢谢分享,再接再厉。
已有 1 人评分论坛币 收起 理由
niuniuyiwan + 5 精彩帖子

总评分: 论坛币 + 5   查看全部评分

使用道具

藤椅
wfh仰望星空 发表于 2015-7-15 13:05:51 |只看作者 |坛友微信交流群
顶起{:2_38:}
已有 2 人评分经验 论坛币 收起 理由
xddlovejiao1314 + 10 + 3 鼓励积极发帖讨论
niuniuyiwan + 5 精彩帖子

总评分: 经验 + 10  论坛币 + 8   查看全部评分

使用道具

板凳
卿士维寒 发表于 2015-7-16 15:07:45 |只看作者 |坛友微信交流群
mark,学习了。
已有 2 人评分经验 论坛币 收起 理由
xddlovejiao1314 + 10 + 3 鼓励积极发帖讨论
niuniuyiwan + 5 精彩帖子

总评分: 经验 + 10  论坛币 + 8   查看全部评分

使用道具

报纸
Alfred_G 学生认证  发表于 2015-9-1 19:25:13 |只看作者 |坛友微信交流群
great~学习了
已有 2 人评分经验 论坛币 收起 理由
xddlovejiao1314 + 10 + 3 鼓励积极发帖讨论
niuniuyiwan + 5 精彩帖子

总评分: 经验 + 10  论坛币 + 8   查看全部评分

使用道具

地板
niuniuyiwan 在职认证  发表于 2015-9-1 19:28:02 |只看作者 |坛友微信交流群
  1. sysuse pop2000, clear
  2. replace maletotal = -maletotal/1e+6
  3. replace femtotal = femtotal/1e+6
  4. gen zero = 0
  5. #delimit ;

  6. twoway
  7. bar maletotal agegrp, horizontal xvarlab(Males)
  8. ||
  9.    bar  femtotal agegrp, horizontal xvarlab(Females)
  10. ||
  11.    sc  agegrp zero     , mlabel(agegrp) mlabcolor(black) msymbol(i)
  12. ||
  13. ,
  14. xtitle("Population in millions") ytitle("")
  15. plotregion(style(none))
  16. ysca(noline) ylabel(none)
  17. xsca(noline titlegap(-3.5))
  18. xlabel(-12 "12" -10 "10" -8 "8" -6 "6" -4 "4" 4(2)12 , tlength(0)
  19. grid gmin gmax)
  20. legend(label(1 Males) label(2 Females)) legend(order(1 2))
  21. title("US Male and Female Population by Age, 2000")
  22. note("Source:  U.S. Census Bureau, Census 2000, Tables 1, 2 and 3")
  23. ;
  24. #delimit cr
复制代码

Graph.png



已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
xddlovejiao1314 + 20 + 20 + 1 + 1 + 1 精彩帖子

总评分: 经验 + 20  论坛币 + 20  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

使用道具

7
niuniuyiwan 在职认证  发表于 2015-9-15 14:33:29 |只看作者 |坛友微信交流群
  1. //修改后
  2. // Circle using function
  3. #delimit ;
  4. twoway (function y = sqrt(1 -(x)^2),
  5. range(-1 1) lwidth(thick) lcolor(red))
  6. (function y = -sqrt(1 - (x)^2),
  7. range(-1 1) lwidth(thick) lcolor(red)), aspect(1)
  8. legend(off) yla(, ang(h)) ytitle(, orient(horiz));
复制代码

Graph.png


关闭图例,调整y标签方向



已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
xddlovejiao1314 + 20 + 20 + 1 + 1 + 1 精彩帖子

总评分: 经验 + 20  论坛币 + 20  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

使用道具

8
hao136986 发表于 2015-10-11 16:38:45 |只看作者 |坛友微信交流群
好!!!!
已有 1 人评分经验 论坛币 收起 理由
xddlovejiao1314 + 10 + 3 鼓励积极发帖讨论

总评分: 经验 + 10  论坛币 + 3   查看全部评分

使用道具

9
xddlovejiao1314 学生认证  发表于 2015-10-12 11:30:22 |只看作者 |坛友微信交流群
好贴,再次mark 一下。
已有 1 人评分论坛币 热心指数 收起 理由
niuniuyiwan + 10 + 2 精彩帖子

总评分: 论坛币 + 10  热心指数 + 2   查看全部评分

使用道具

10
niuniuyiwan 在职认证  发表于 2015-10-15 11:58:52 |只看作者 |坛友微信交流群
  1. sysuse nlsw88, clear
  2. #delimit ;
  3. graph hbar wage, over(ind, sort(1)) over(collgrad)
  4.   title("Average hourly wage, 1988, women aged 34-46", span)
  5.   subtitle(" ")
  6.   note("Source:  1988 data from NLS, U.S. Dept. of Labor, Bureau of Labor Statistics", span)
  7.   ysize(7) ;
  8. #delimit cr
复制代码

Graph.png


使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-24 18:40