楼主: 匿名
20373 212

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

11
niuniuyiwan 在职认证  发表于 2015-8-22 17:38:44
  1. // Graph - Slide

  2. twoway                                                                       ///
  3.   (scatteri 6 0 "Kinds of graphs Stata can make", mlabsize(huge) pstyle(p1)) ///
  4.   (scatteri 5 0 "Schemes for controlling look of graphs", mlabsize(huge)     ///
  5.       pstyle(p1))                                                            ///
  6.   (scatteri 4 0 "Structure of graph commands", mlabsize(huge) pstyle(p1))    ///
  7.   (scatteri 3 0 "graph options", mlabsize(huge) pstyle(p1))                  ///
  8.   (scatteri 2 0 "Building complex graphs", mlabsize(huge) pstyle(p1))        ///
  9.   (scatteri 1 0 "Additional examples", mlabsize(huge) pstyle(p1)),           ///
  10.       title("Overview")                                                      ///
  11.    xlabel(-.05 1) ylabel(-1 7)                                               ///
  12.    xscale(off) yscale(off)                                                   ///
  13.    legend(off)                                                               ///
  14.    note("Stata graphics are fun and easy" "Stata graphics are powerful",     ///
  15.          ring(0))
复制代码

Graph.png


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

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

12
niuniuyiwan 在职认证  发表于 2015-8-22 22:49:33
  1. twoway function y=-3*(1-(abs(x)/2)^0.5)^0.5, range(-4 4) || ///
  2.         function y= (1-(abs(x)-1)^2)^0.5, range(-4 4) yscale(range(-3 1)) ///
  3.         graphregion(fcolor(pink)) title("七夕" , size(vhuge)  ///
  4.         margin(bottom)) legend(off) yscale(off) xscale(off)
复制代码

Graph.png



13
niuniuyiwan 在职认证  发表于 2015-8-23 08:45:23
  1. // histogram

  2. sysuse auto, clear

  3. twoway histogram mpg if !foreign,                              ///
  4. start(10) width(2) freq bfcolor(none) blcolor(pink)            ///
  5. || histogram mpg if foreign, freq start(10) width(2) barw(1.8) ///
  6. bfcolor(none) blcolor(blue)                                    ///
  7. legend(order(1 "Domestic" 2 "Foreign") pos(2) ring(0) col(1))
复制代码

1.png



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

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

14
niuniuyiwan 在职认证  发表于 2015-8-23 08:47:44
1.png
  1. // Text that varies in size due to a calculated factor
  2.   
  3. clear programs
  4.        
  5.         *--------------- begin example ---------------------
  6.         program s
  7.        
  8.         sysuse auto, clear
  9.         tempname hdle
  10.         tempfile info
  11.         postfile `hdle' str20  variable missings using `info'
  12.        
  13.         qui ds, has(type numeric)
  14.        
  15.         qui foreach var in `r(varlist)'{
  16.             /*want more missings
  17.             to make this interesting */
  18.             replace `var'=. if runiform()<0.1
  19.             qui count if `var'==.
  20.             post `hdle' ("`var'") (r(N))
  21.           }
  22.        
  23.         postclose `hdle'
  24.        
  25.         use `info', clear
  26.         gen number=_n
  27.         list, noobs
  28.         gen x = 1
  29.        
  30.         sum missings, meanonly
  31.         gen factor = missings/r(mean)
  32.         levelsof variable, local(aa)
  33.        
  34.         local a=1        
  35.        
  36.         foreach i of local aa {
  37.        
  38.         local f = factor[`a'
  39.         local txt `"`txt' text(`a' 1 "`i'", size(*`f'))"'
  40.         capture `++a'
  41.         }
  42.        
  43.         scatter number x, msymbol(i)  ///
  44.              xtitle("") xscale(off)   ///
  45.              ytitle("") yscale(off)   ///
  46.              plotregion(lstyle(none)) ///
  47.              `txt'        
  48.         *----------------- end example -----------------------------
  49.         end
  50.        
  51.         s                 //calls program "s" above
复制代码


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

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

15
niuniuyiwan 在职认证  发表于 2015-8-23 20:26:03
1 sysuse uslifeexp.dta, clear
2 graph twoway line le year
3 /* OR */
4 twoway line le year
5 /* OR */
6 line le year

1.PNG



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

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

16
niuniuyiwan 在职认证  发表于 2015-8-23 20:27:56
1 sysuse uslifeexp.dta, clear
2 graph twoway line le year
3 /* OR */
4 twoway line le year
5 /* OR */
6 line le year, scheme(s1mono)

1.PNG



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

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

17
niuniuyiwan 在职认证  发表于 2015-8-23 20:29:45
1 sysuse uslifeexp.dta, clear
2 line le year, scheme(economist)
3 /* to see list of
4 scheme names:
5 graph query, schemes
6 to change default scheme:
7 set scheme schemename
8 */

1.PNG



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

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

18
niuniuyiwan 在职认证  发表于 2015-8-23 20:32:04
1 *Multiple Dependent Variables
2
3 sysuse uslifeexp.dta, clear
4 line le_wmale le_wfemale le_bmale le_bfemale year

1.PNG



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

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

19
niuniuyiwan 在职认证  发表于 2015-8-23 20:37:32
1 *Adding Text
2 sysuse uslifeexp.dta, clear
3 line le_wmale le_wfemale le_bmale le_bfemale year  ///
4 , text(32 1920 "{bf:1918} {it:Influenza} Pandemic", place(3))

1.PNG



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

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

20
niuniuyiwan 在职认证  发表于 2015-8-24 09:26:43
1 // Shade Part of a Graph
2
3 sysuse auto, clear   
4
5 summarize price, mean
6 local mean = r(mean)
7 kdensity price, gen(x h)
8
9 line h x, || area h x if  x < `mean'

1.png



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

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

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-1 00:32