请选择 进入手机版 | 继续访问电脑版
楼主: niuniuyiwan
5274 6

[Stata] 如何记录和应用Graph editor 中的操作命令? [推广有奖]

  • 7关注
  • 91粉丝

VIP

学科带头人

89%

还不是VIP/贵宾

-

威望
0
论坛币
12641 个
通用积分
1551.0438
学术水平
1116 点
热心指数
1164 点
信用等级
1058 点
经验
8347 点
帖子
1625
精华
1
在线时间
2447 小时
注册时间
2010-10-10
最后登录
2024-4-18

niuniuyiwan 在职认证  发表于 2015-12-31 19:32:41 |显示全部楼层 |坛友微信交流群
相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

[Stata]如何记录和应用Graph editor 中的操作命令?

通过Stata Graph editor 可以很方便地对图形加以美化修改,但手动操作相应
的代码并未自动生成,这时可以借助Stata graph editor recorder来加以记录,
再将gr_edit添加在所记录语句前,这样操作代码便应用到了整幅图形的编辑中。
1.生成图像
  1. sysuse auto,clear
  2. histogram mpg
复制代码

Graph.png

2.
(1)首先右键点击start graph editor
(2)然后点击功能区中的小红点(Start recording)
(3)以修改直方柱颜色为例(选择lime),完毕后再次点击小红点(End recording),此时在自动弹出的对话框中命令保存即可(此     处暂记为1.grec)。

1.gif


(4)

方法一:
  1. sysuse auto,clear
  2. histogram mpg,play("1.grec")
复制代码
方法二:
          在Do-file Editor中打开1.grec:

1.png

  1. StataFileTM:00001:01100:GREC:                          :
  2. 00004:00004:00001:
  3. *! classname: twowaygraph_g
  4. *! family: twoway
  5. *! date: 31 Dec 2015
  6. *! time: 19:25:31
  7. *! graph_scheme: s1color
  8. *! naturallywhite: 1
  9. *! end

  10. // File created by Graph Editor Recorder.
  11. // Edit only if you know what you are doing.

  12. .plotregion1.plot1.style.editstyle area(shadestyle(color(lime))) editcopy
  13. .plotregion1.plot1.style.editstyle area(linestyle(color(lime))) editcopy
  14. // plot1 color


  15. // <end>
复制代码
     然后在上面所记录的语句前添加加gr_edit即可(去掉editcopy)。
  1. sysuse auto,clear
  2. histogram mpg
  3. gr_edit plotregion1.plot1.style.editstyle area(shadestyle(color(lime)))
复制代码

Graph.png


Graph.png


二维码

扫码加我 拉你入群

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

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

关键词:editor GRAPH GRAP Edit Ito command 如何

回帖推荐

xddlovejiao1314 发表于3楼  查看完整内容

感谢师弟回来多分享好东西啊~
已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
Sunknownay + 3 + 3 + 3 精彩帖子
xddlovejiao1314 + 100 + 100 + 5 + 5 + 5 精彩帖子

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

niuniuyiwan 在职认证  发表于 2016-1-1 17:08:43 |显示全部楼层 |坛友微信交流群
Stata tip 81: A table of graphs
  1. set scheme sj
  2. sysuse auto, clear
  3. fillin rep78 foreign
  4. twoway scatter price mpg, by(foreign rep78, cols(5) compact)
复制代码

a1.png



  1. egen group = group(foreign rep78)
  2. label define group     ///
  3.         1  "Poor"          ///
  4.         2  "Fair"          ///
  5.         3  "Average"       ///
  6.         4  "Good"          ///
  7.         5  "Excellent"     ///
  8.         6  " "             ///
  9.         7  " "             ///
  10.         8  " "             ///
  11.         9  " "             ///
  12.         10 " "
  13. label value group group
  14. twoway scatter price mpg,     ///
  15.         by(group, cols(5)         ///
  16.         r1title("Car type",       ///
  17.         orientation(rvertical)    ///
  18.         size(medsmall))           ///
  19.         t1title("Repair status",  ///
  20.         size(medsmall))           ///
  21.         note("") compact)
复制代码

a2.png



启动Graph Editor,点击小红点(Start Recording),右侧Object Browser:



119 stata tips.bmp





双击r1title[5]---填入Domestic-->依次调整Box和Format选项卡下内容完成修改

tips1.bmp



tips2.bmp


tips3.bmp



类似双击r1title[10]---填入Domestic-->依次调整Box和Format选项卡下内容完成修改,保存1.grec:在Do-file Editor中打开:
  1. StataFileTM:00001:01100:GREC:                          :
  2. 00004:00004:00001:
  3. *! classname: bygraph_g
  4. *! family: by
  5. *! date:  1 Jan 2016
  6. *! time: 17:42:16
  7. *! graph_scheme: sj
  8. *! naturallywhite: 1
  9. *! end

  10. // File created by Graph Editor Recorder.
  11. // Edit only if you know what you are doing.

  12. .plotregion1.r1title[5].style.editstyle drawbox(yes) editcopy
  13. .plotregion1.r1title[5]._set_orientation rvertical
  14. .plotregion1.r1title[5].text = {}
  15. .plotregion1.r1title[5].text.Arrpush Domestic
  16. .plotregion1.r1title[5].as_textbox.setstyle, style(yes)
  17. // r1title[5] edits

  18. // r1title[5] edits

  19. .plotregion1.r1title[10].as_textbox.setstyle, style(yes)
  20. .plotregion1.r1title[10].text = {}
  21. .plotregion1.r1title[10].text.Arrpush Foreign
  22. // r1title[10] edits

  23. // r1title[10] edits


  24. // <end>
复制代码
包含以上手工操作的完整代码如下所述:
  1. set scheme sj
  2. sysuse auto, clear
  3. fillin rep78 foreign
  4. twoway scatter price mpg, by(foreign rep78, cols(5) compact)
  5. egen group = group(foreign rep78)
  6. label define group     ///
  7.         1  "Poor"          ///
  8.         2  "Fair"          ///
  9.         3  "Average"       ///
  10.         4  "Good"          ///
  11.         5  "Excellent"     ///
  12.         6  " "             ///
  13.         7  " "             ///
  14.         8  " "             ///
  15.         9  " "             ///
  16.         10 " "
  17. label value group group
  18. twoway scatter price mpg,     ///
  19.         by(group, cols(5)         ///
  20.         r1title("Car type",       ///
  21.         orientation(rvertical)    ///
  22.         size(medsmall))           ///
  23.         t1title("Repair status",  ///
  24.         size(medsmall))           ///
  25.         note("") compact)
  26. gr_edit plotregion1.r1title[5].style.editstyle drawbox(yes) editcopy
  27. gr_edit plotregion1.r1title[5]._set_orientation rvertical
  28. gr_edit plotregion1.r1title[5].text = {}
  29. gr_edit plotregion1.r1title[5].text.Arrpush Domestic
  30. gr_edit plotregion1.r1title[5].as_textbox.setstyle, style(yes)

  31. gr_edit plotregion1.r1title[10].as_textbox.setstyle, style(yes)
  32. gr_edit plotregion1.r1title[10].text = {}
  33. gr_edit plotregion1.r1title[10].text.Arrpush Foreign
复制代码



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

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

使用道具

xddlovejiao1314 学生认证  发表于 2016-1-3 10:03:24 |显示全部楼层 |坛友微信交流群
感谢师弟回来多分享好东西啊~
已有 1 人评分热心指数 收起 理由
niuniuyiwan + 5 精彩帖子

总评分: 热心指数 + 5   查看全部评分

使用道具

niuniuyiwan 在职认证  发表于 2016-1-4 00:22:33 来自手机 |显示全部楼层 |坛友微信交流群
xddlovejiao1314 发表于 2016-1-3 10:03
感谢师弟回来多分享好东西啊~
祝师兄一切都好!

使用道具

guyiyin2003 发表于 2020-2-21 12:13:37 |显示全部楼层 |坛友微信交流群
谢谢分享

使用道具

13120193966 学生认证  发表于 2020-2-22 11:15:02 |显示全部楼层 |坛友微信交流群
撒花感谢~~

使用道具

newfei188 发表于 2024-1-7 18:34:49 来自手机 |显示全部楼层 |坛友微信交流群
很好很好,太好了

使用道具

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

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

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

GMT+8, 2024-4-19 08:43