楼主: 匿名
20345 212

[Stata] [Stata] 如何添加直角坐标系及极坐标系及SDAS_绘图实例 [推广有奖]

匿名网友
楼主
匿名网友  发表于 2015-8-12 08:16:19 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

本贴转自:http://www.surveydesign.com.au/tipsgraphs.html


1.PNG

Graph.png


21.PNG

Graph1.png


_该例讲述如何在图像中添加直角坐标系


极坐标系须先安装polar命令

31.PNG

1.png

41.PNG

2.png

51.PNG

3.png

4.png

5.png

1.png

2.png

61.PNG

Graph.png


link.gif

二维码

扫码加我 拉你入群

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

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

关键词:Stata tata 坐标系 Das SDA 平面 坐标系 如何 black local

已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
玄一无相 + 100 + 3 + 3 + 3 获益匪浅 用心良苦
xddlovejiao1314 + 100 + 100 + 5 + 5 + 5 精彩帖子

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

本帖被以下文库推荐

沙发
rrjj101022 发表于 2015-8-12 08:51:21
谢谢分享~~~
已有 2 人评分经验 论坛币 收起 理由
xddlovejiao1314 + 10 + 3 鼓励积极发帖讨论
niuniuyiwan + 5 感谢支持

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

藤椅
niuniuyiwan 在职认证  发表于 2015-8-19 14:22:14
  1. sysuse nlsw88, clear       

  2. generate g=max(grade,8)
  3. label  var g "Years of education"       
  4. rename  married m       
  5. collapse wage, by(g m)       
  6. generate  w=round(wage,.01)       
  7. summarize wage, meanonly       
  8. generate  c=round((wage-r(min))/(r(max)-r(min))*255)       
  9. quiet levelsof c, loc(cs)       
  10. local g               
  11. foreach c of loc cs {       
  12.    local c1=120+round(`c'/2)
  13.    local c2=255-round(`c'/2)       
  14.    local m mc("`c2' `c2' `c1'")       
  15.    local g `g'||sc m g if c==`c', ms(S) msize(ehuge) `m'
  16. }       
  17. local g `g'||sc m g, ms(i) mlab(w) mlabp(0)       
  18. local g `g' leg(off) yla(-.75 " " 0 "N" 1 "Y" 1.75 " ", notick)            
  19. local g `g' xla(7 " " 8/18 19 " ", notick)               

  20. twoway `g'  scheme(s1mono) ti(Wage heat map) xsize(8) ysize(5)
复制代码

Graph.png



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

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

板凳
niuniuyiwan 在职认证  发表于 2015-8-19 14:24:36
  1. clear               
  2.                
  3.   input input low   high  mean       
  4.          1     1.6   2.2  1.9       
  5.          2     1.5   2.3  1.9
  6.          5     2.9   0.01 1.9
  7.                  3     1.0   2.9  1.9
  8.          4     0.5   3.2  1.9       
  9.   end                                               
  10.                                                                                
  11.   label var input "Input"       
  12.   label var low   "Low value"       
  13.   label var high  "High value"       
  14.   label var mean  "Mean"       
  15.                                                                                
  16.   label define inputlbl             ///       
  17.   1 "Annual Donations in U.S."      ///
  18.   2 "Seroprevalence"                ///
  19.   3 "Exposures per Donation"            ///
  20.   4 "Probability of Transmission"   ///       
  21.   5 "Sensitivity of Test"                         
  22.                                  
  23.   label val input inputlbl       
  24.                                                        
  25.   gen sens = high-low       
  26.   sort sens
  27.                                                                                
  28.   local ml1 = (2.2+1.9)/2       
  29.   local mh1 = (1.6+1.9)/2       
  30.   local ml2 = (2.3+1.9)/2       
  31.   local mh2 = (1.5+1.9)/2       
  32.   local ml3 = (2.9+1.9)/2       
  33.   local mh3 = (1.0+1.9)/2       
  34.   local ml4 = (3.2+1.9)/2       
  35.   local mh4 = (0.5+1.9)/2       
  36.   local ml5 = (2.9+1.9)/2       
  37.   local mh5 = (0  +1.9)/2       
  38.                
  39.                
  40. local format fcolor(white) lcolor(white)
  41.                                                                                
  42.   twoway                                                                   ///
  43.   (rbar low mean input, horizontal)                                        ///
  44.   (rbar mean high input, horizontal),                                      ///
  45.   ylabel(, val angle(horizontal)) xsize(7.1) ysize(5.2) scheme(sj)         ///
  46.   xtitle(" " "Predicted Cases of Transfusion-Transmitted T.   Cruzi")      ///
  47.   title("Sensitivity of Results to Inputs") subtitle("Test Once Scenario") ///
  48.   legend(label(1 "Low Input Values") label(2 "High Input Values") rows(2)) ///
  49.   text(5 `ml5' "93.5%", box j(center)  margin(l+1 r+1 t+1 b+1)   `format') ///
  50.   text(5 `mh5' "99.99%", box j(center) margin(l+1 r+1 t+1 b+1)   `format') ///
  51.   text(4 `ml4' "5%", box j(center)     margin(l+1 r+1 t+1 b+1)   `format') ///
  52.   text(4 `mh4' "0.8%", box j(center)   margin(l+1 r+1 t+1 b+1)   `format') ///
  53.   text(3 `ml3' "3", box j(center)      margin(l+1 r+1 t+1 b+1)   `format') ///
  54.   text(3 `mh3' "1", box j(center)      margin(l+1 r+1 t+1 b+1)   `format') ///
  55.   text(2 1.4 "1:28,600", box           margin(l+1 r+1 t+1 b+1)   `format'  ///
  56.   placement(9) j(right))                                                   ///
  57.   text(2 2.4 "1:18,200", box           margin(l+1 r+1 t+1 b+1)   `format'  ///
  58.   placement(3) j(left))                                                    ///
  59.   text(1 1.5 "13.4 million", box       margin(l+1 r+1 t+1 b+1)   `format'  ///
  60.   placement(9) j(right))                                                   ///
  61.   text(1 2.4 "19 million", box         margin(l+1 r+1 t+1 b+1)   `format'  ///
  62.   placement(3) j(left))       
复制代码

Graph.png


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

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

报纸
niuniuyiwan 在职认证  发表于 2015-8-19 14:26:23
  1. // Controlling the side of the graph that the axis is on

  2. sysuse auto, clear

  3. twoway ///
  4. (histogram mpg, width(5) yscale(alt  axis(1)) ) ///
  5. (line  weight mpg, yaxis(2) yscale(alt axis(2)) sort)
复制代码

Graph.png



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

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

地板
niuniuyiwan 在职认证  发表于 2015-8-19 23:27:59
  1. // Grid on top of graph

  2. ssc install freduse, replace  //gets program online
  3. freduse MPRIME, clear
  4. generate ym = mofd(daten)
  5. tsset ym, monthly             //sets for time series
  6. twoway                                                                    ///
  7. function y=20.705,range(119 130) recast(area) color(gs12) base(4.7025) || ///
  8. function y=20.705,range(166 182) recast(area) color(gs12) base(4.7025) || ///
  9. function y=20.705,range(240 274) recast(area) color(gs12) base(4.7025) || ///
  10. function y= 5    ,range(119 274) lstyle(grid)                          || ///
  11. function y=10    ,range(119 274) lstyle(grid)                          || ///
  12. function y=15    ,range(119 274) lstyle(grid)                          || ///
  13. function y=20    ,range(119 274) lstyle(grid)                          || ///
  14. function y=ym(1980,11), range(4.7025 20.705) horizontal lstyle(grid)   || ///
  15. tsline MPRIME if tin(1970m1,1990m1), xlabel(,format(%tm)) lstyle(p1)      ///
  16. legend(order(5 1 "Recession")) tlabel(,grid) scheme(s2color)

  17. *(Maarten Buis - Stata list,  30 October 2011)
复制代码

Graph.png



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

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

7
niuniuyiwan 在职认证  发表于 2015-8-20 12:51:41
  1. // stacked bar graph

  2. sysuse auto, clear
  3. twoway__histogram_gen mpg if foreign, gen(freq_foreign x) ///
  4. freq start(0) width(2)       
  5. drop if missing(x)
  6. keep freq_foreign x
  7. save a1, replace

  8. sysuse auto, clear
  9. twoway__histogram_gen mpg if !foreign, gen(freq_domestic x) ///
  10. freq start(0) width(2)       
  11. drop if missing(x)
  12. keep freq_domestic x mpg

  13. merge 1:1         x using a1

  14. mvencode freq_domestic  freq_foreign , mv(.=0)
  15.        
  16. egen freq = rowtotal(freq_domestic  freq_foreign )

  17. twoway                                                                        ///
  18. (bar freq_domestic x if freq < ., barw(2) bcolor(blue) xsc(r(10 .)) )         ///
  19. rbar freq_domestic freq x if freq < ., barw(2) bcolor(red)                    ///
  20. legend(order(1 "Domestic" 2 "Foreign") pos(11) col(1) ring(0))                ///
  21. xtitle("`: var label mpg'") ytitle(Frequency) xla(10(5)45, alt) yla(, ang(h)) ///
  22. xsc(r(10 .))
复制代码

Graph.png



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

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

8
niuniuyiwan 在职认证  发表于 2015-8-20 13:21:29
  1. // Shade Part of a Graph

  2. sysuse auto, clear
  3. sort mpg
  4. generate x=_n
  5. gen max=ceil(_N/10)*10

  6. summarize mpg, detail

  7. twoway ///
  8. (area max x   if inrange(x, `=r(p1)', `=r(p25)'),   ///
  9. lcolor(bg) fcolor(green)  fintensity(inten20))      ///
  10. (area  max x   if inrange(x, `=r(p75)', `=r(p99)'), ///
  11. lcolor(bg) fcolor(green) fintensity(inten20))       ///
  12. (line x mpg),legend(off) plotregion(margin(zero))   ///
  13. xtitle("MPG")                                       ///
  14. xlabel(10 `=r(p1)' `=r(p25)' `=r(p75)' `=r(p99)' )  ///
  15. yscale(range(0 `=_N'))
复制代码

Graph.png



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

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

9
niuniuyiwan 在职认证  发表于 2015-8-20 13:22:51
  1. sysuse auto, clear

  2. graph bar  mpg, asyvars  over(rep78) ///
  3. bar(1, bcolor(red*0.4))              ///
  4. bar(2, bcolor(red*0.2))              ///
  5. bar(3, bcolor(blue*0.2))             ///
  6. bar(4, bcolor(blue*0.4))             ///
  7. bar(5, bcolor(blue*0.6))             ///
  8. legend(row(1) title("REP78"))        ///
  9. title("Mean MPG for rep78")
复制代码

Graph.png



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

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

10
niuniuyiwan 在职认证  发表于 2015-8-20 15:25:08
  1. // box plot

  2. sysuse auto, clear       
  3.                                                
  4. statsby "su mpg" mean=r(mean) max=r(max) min=r(min) sd=r(sd), by(rep78)
  5.        
  6. // here k = 1; tune to choice
  7. gen meanpsd = mean + sd
  8. gen meanmsd = mean - sd
  9.                                                
  10. // use -line- or -connected- not -scatter-
  11. twoway scatter mean rep78 ||                            ///
  12. rbar mean max rep78, bcolor(none) barw(0.2) ||          ///
  13. rbar mean min rep78, bcolor(none) barw(0.2) ||          ///
  14. rbar meanmsd meanpsd rep78 , barw(0.1) bcolor(red) || , ///
  15. legend(off) ytitle(Miles per gallon) yla(, ang(h))      ///
  16. note(red bars: mean +/- sd; empty bars show range)
复制代码

Graph.png



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

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

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-31 14:25