楼主: 6513
5297 6

[作图问题求助] stata如何在线图加数字刻度,数字标签? [推广有奖]

  • 2关注
  • 13粉丝

博士生

75%

还不是VIP/贵宾

-

TA的文库  其他...

读一本好书

威望
0
论坛币
17091 个
通用积分
586.8077
学术水平
22 点
热心指数
18 点
信用等级
16 点
经验
28619 点
帖子
274
精华
0
在线时间
309 小时
注册时间
2013-1-20
最后登录
2024-4-17

楼主
6513 在职认证  发表于 2021-8-18 11:19:59 |只看作者 |坛友微信交流群|倒序 |AI写论文
相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

在做线图的时候,按照每一年分城乡统计均值,想在图中把每一年均值的数字标签表示出来,应该怎么写命令?
这是我原来的命令

graph twoway line x year ,by(chengxiang)connect(line)clpattern (longdash) lcolor (grey) legend(row(3)position(10)ring(0))xtitle("") ytitle("Mean total number of children")xlabel(2012 2013 2015 2017)ylabel(minmax)yaxis(1 2) saving(Fig_m1,replace)


------------------------ copy starting from the next line -----------------------
  1. * Example generated by -dataex-. For more info, type help dataex
  2. clear
  3. input float(x chengxiang year)
  4. 2.685028 0 2013
  5. 2.3698075 1 2017
  6. 2.527976 0 2015
  7. 2.685028 1 2013
  8. 2.794905 1 2012
  9. 2.794905 0 2012
  10. 2.794905 1 2012
  11. 2.3698075 1 2017
  12. 2.527976 1 2015
  13. 2.3698075 1 2017
  14. 2.794905 1 2012
  15. 2.3698075 0 2017
  16. 2.527976 1 2015
  17. 2.685028 0 2013
  18. 2.3698075 0 2017
  19. 2.527976 1 2015
  20. 2.527976 0 2015
  21. 2.794905 1 2012
  22. 2.794905 0 2012
  23. 2.3698075 0 2017
  24. 2.3698075 1 2017
  25. 2.527976 0 2015
  26. 2.685028 1 2013
  27. 2.527976 1 2015
  28. 2.3698075 1 2017
  29. 2.3698075 1 2017
  30. 2.794905 1 2012
  31. 2.527976 1 2015
  32. 2.685028 0 2013
  33. 2.3698075 0 2017
  34. 2.685028 0 2013
  35. 2.3698075 0 2017
  36. 2.3698075 0 2017
  37. 2.3698075 1 2017
  38. 2.3698075 1 2017
  39. 2.3698075 1 2017
  40. 2.3698075 0 2017
  41. 2.527976 1 2015
  42. 2.685028 0 2013
  43. 2.3698075 1 2017
  44. 2.3698075 0 2017
  45. 2.794905 0 2012
  46. 2.794905 1 2012
  47. 2.527976 0 2015
  48. 2.794905 0 2012
  49. 2.794905 0 2012
  50. 2.3698075 0 2017
  51. 2.3698075 0 2017
  52. 2.3698075 1 2017
  53. 2.527976 0 2015
  54. 2.3698075 1 2017
  55. 2.527976 1 2015
  56. 2.527976 1 2015
  57. 2.3698075 0 2017
  58. 2.3698075 1 2017
  59. 2.794905 1 2012
  60. 2.527976 1 2015
  61. 2.685028 1 2013
  62. 2.794905 1 2012
  63. 2.685028 0 2013
  64. 2.3698075 1 2017
  65. 2.3698075 1 2017
  66. 2.527976 0 2015
  67. 2.527976 0 2015
  68. 2.794905 1 2012
  69. 2.685028 0 2013
  70. 2.3698075 0 2017
  71. 2.685028 1 2013
  72. 2.794905 0 2012
  73. 2.685028 1 2013
  74. 2.794905 0 2012
  75. 2.3698075 1 2017
  76. 2.685028 0 2013
  77. 2.794905 1 2012
  78. 2.527976 0 2015
  79. 2.794905 1 2012
  80. 2.685028 0 2013
  81. 2.3698075 0 2017
  82. 2.3698075 1 2017
  83. 2.794905 0 2012
  84. 2.3698075 1 2017
  85. 2.527976 1 2015
  86. 2.794905 1 2012
  87. 2.794905 0 2012
  88. 2.685028 0 2013
  89. 2.794905 1 2012
  90. 2.794905 1 2012
  91. 2.527976 0 2015
  92. 2.3698075 1 2017
  93. 2.794905 1 2012
  94. 2.794905 1 2012
  95. 2.3698075 0 2017
  96. 2.527976 1 2015
  97. 2.794905 1 2012
  98. 2.3698075 0 2017
  99. 2.794905 1 2012
  100. 2.794905 0 2012
  101. 2.685028 0 2013
  102. 2.527976 0 2015
  103. 2.685028 0 2013
  104. end
  105. label values chengxiang chengxiang
  106. label def chengxiang 0 "Rural", modify
  107. label def chengxiang 1 "Urban", modify
复制代码

------------------ copy up to and including the previous line ------------------


二维码

扫码加我 拉你入群

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

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

关键词:Stata tata including generated position stata线图;数字标签;数字刻度

沙发
zdlspace 学生认证  发表于 2021-8-18 12:39:53 |只看作者 |坛友微信交流群
你这城乡数字怎么一模一样啊,
  1. bys chengxiang year: egen meanx=mean(x)
  2. sepscatter x year,sep(chengxiang) recast(connected) clpattern(longdash) lcolor(grey) ///
  3.                                                  mlab(meanx) xtitle("") ytitle("Mean total number of children") ///
  4.                                                 xlabel(2012 2013 2015 2017) yaxis(1 2) ///
  5.                                                 legend(row(3) position(10) ring(0))  saving(Fig_m1,replace)
复制代码

截屏2021-08-18 12.38.05.png

截屏2021-08-18 12.38.05.png (48.36 KB)

截屏2021-08-18 12.38.05.png

Raymond
Stata 17.0, MP(4)

使用道具

藤椅
6513 在职认证  发表于 2021-8-18 13:23:59 |只看作者 |坛友微信交流群
zdlspace 发表于 2021-8-18 12:39
你这城乡数字怎么一模一样啊,
我也不是很清楚,可能是这个100个样本的问题吧

使用道具

板凳
zdlspace 学生认证  发表于 2021-8-18 13:26:19 |只看作者 |坛友微信交流群
6513 发表于 2021-8-18 13:23
我也不是很清楚,可能是这个100个样本的问题吧
你数字也用点心啊,即使是随便给数据,也别给的一模一样啊,毕竟要画图,一样的数据画出来的图完全重合

使用道具

报纸
zdlspace 学生认证  发表于 2021-8-18 15:45:01 |只看作者 |坛友微信交流群
  1. collapse zinv,by(chengxiang year)
  2. format zinv %5.2f
  3. gen pos=12
  4. replace pos=1 if year==2012
  5. replace pos=11 if year==2017
  6. twoway connected zinv year if chengxiang==1 ,mlab(zinv) mlabv(pos) mlabgap(*1.5)  ///
  7.       || connected zinv year if chengxiang==0 , lp(dash) msymbol(Th) mlab(zinv) mlabv(pos) mlabgap(*1.5) ///
  8.    ytitle("平均子女数") ylab(,labsize(*0.8) angle(h)) xlab(,labsize(*0.8)) ///
  9.    legend(order(1 "城市" 2 "农村") ring(0) pos(1) row(2) region(fc(none) lp(blank))) WechatIMG73.jpeg
复制代码

已有 2 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
Sunknownay + 3 + 3 + 3 热心帮助其他会员
6513 + 5 + 2 + 2 + 1 精彩帖子

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

Raymond
Stata 17.0, MP(4)

使用道具

地板
offandon 发表于 2021-10-17 10:58:28 |只看作者 |坛友微信交流群
很厉害。

使用道具

7
115861 发表于 2024-1-20 09:43:57 |只看作者 |坛友微信交流群
zdlspace 发表于 2021-8-18 15:45
求教如何在柱图中显示数字标签,graph bar知道用blabel,但是因为要做变量及变量增速的组合图,这种用twoway 情况下如何显示柱状图数据标签呢?谢谢

使用道具

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

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

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

GMT+8, 2024-4-30 17:26