- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 14446 个
- 通用积分
- 1962.3850
- 学术水平
- 1119 点
- 热心指数
- 1167 点
- 信用等级
- 1061 点
- 经验
- 8523 点
- 帖子
- 1629
- 精华
- 1
- 在线时间
- 2492 小时
- 注册时间
- 2010-10-10
- 最后登录
- 2025-12-19
已卖:1980份资源
学科带头人
还不是VIP/贵宾
- 威望
- 0 级
- 论坛币
 - 14446 个
- 通用积分
- 1962.3850
- 学术水平
- 1119 点
- 热心指数
- 1167 点
- 信用等级
- 1061 点
- 经验
- 8523 点
- 帖子
- 1629
- 精华
- 1
- 在线时间
- 2492 小时
- 注册时间
- 2010-10-10
- 最后登录
- 2025-12-19
 | 开心 2025-9-24 13:52:14 |
|---|
签到天数: 344 天 连续签到: 1 天 [LV.8]以坛为家I
|
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
- sysuse sp500, clear
- #delimit ;
- histogram volume, freq
- xaxis(1 2)
- ylabel(0(10)60, grid)
- xlabel(12321 "mean"
- 9735 "-1 s.d."
- 14907 "+1 s.d."
- 7149 "-2 s.d."
- 17493 "+2 s.d."
- 20078 "+3 s.d."
- 22664 "+4 s.d.", axis(2) grid gmax)
- xtitle("", axis(2))
- subtitle("S&P 500, January 2001 - December 2001")
- note("Source: Yahoo!Finance and Commodity Systems, Inc.")
- ;
- #delimit cr
复制代码- sysuse sp500, clear
- #delimit ;
- histogram volume, freq normal
- xaxis(1 2)
- ylabel(0(10)60, grid)
- xlabel(12321 "mean"
- 9735 "-1 s.d."
- 14907 "+1 s.d."
- 7149 "-2 s.d."
- 17493 "+2 s.d."
- 20078 "+3 s.d."
- 22664 "+4 s.d."
- , axis(2) grid gmax)
- xtitle("", axis(2))
- subtitle("S&P 500, January 2001 - December 2001")
- note("Source: Yahoo!Finance and Commodity Systems, Inc.")
- ;
- #delimit cr
复制代码 |
<--------grid代表网格
<--------添加normal代表正态曲线 | 自定义直方图宽度的一种方法:- sysuse auto, clear
- su mpg
- local width=1
- histogram mpg ,width(`width') freq ///
- addplot(function y =`width'*`=_N'*normalden(x,`r(mean)',`r(sd)'), ra(10 45))
- sysuse auto, clear
- su mpg
- local width=2 // <-----------根据需要改变
- histogram mpg ,width(`width') freq ///
- addplot(function y =`width'*`=_N'*normalden(x,`r(mean)',`r(sd)'), ra(10 45))
- sysuse auto, clear
- su mpg
- local width=3 // <-----------根据需要改变
- histogram mpg ,width(`width') freq ///
- addplot(function y =`width'*`=_N'*normalden(x,`r(mean)',`r(sd)'), ra(10 45))
- sysuse auto, clear
- su mpg
- local width=4 // <-----------根据需要改变
- histogram mpg ,width(`width') freq ///
- addplot(function y =`width'*`=_N'*normalden(x,`r(mean)',`r(sd)'), ra(10 45))
复制代码 |
| - //Combining many graphs on a page
- sysuse auto, clear
- graph drop _all
- drop make
- foreach i of varlist _all{
- capture confirm numeric variable `i' if _rc==0
- histogram `i', name(`i')
- local z "`z' `i'"
- graph combine `z'
- }
复制代码 多变量直方图的绘制,可使用循环语句,合并到同一幅图中。 |
|
条形图 1. 对于同一数据条形图的绘制,由于hbar支持的标签长度更长,因此使用graph hbar要比graph bar 好些。
2. 使用graph bar|hbar|box|hbox|dot 描述类别变量时,选项为over( ) ,不是by( ) |
- sysuse citytemp, clear
- #delimit ;
- graph bar tempjuly tempjan, over(region) bargap(-30)
- legend( label(1 "July") label(2 "January") )
- ytitle("Degrees Fahrenheit")
- title("Average July and January temperatures")
- subtitle("by regions of the United States")
- note("Source: U.S. Census Bureau, U.S. Dept. of Commerce") ;
- #delimit cr
复制代码 |
| - sysuse citytemp, clear
- #delimit ;
- graph bar tempjuly tempjan, over(region) bargap(-30)
- legend( label(1 "July") label(2 "January") )
- ytitle("Degrees Fahrenheit")
- title("Average July and January temperatures")
- subtitle("by regions of the United States")
- note("Source: U.S. Census Bureau, U.S. Dept. of Commerce")
- blabel(bar, position(inside) format(%9.1f) color(white)) ;
- #delimit cr
复制代码 |
| - sysuse citytemp, clear
- #delimit ;
- graph bar (mean) tempjuly tempjan,
- over(division, label(labsize(*.75)))
- over(region)
- bargap(-30) nofill
- ytitle("Degrees Fahrenheit")
- legend( label(1 "July") label(2 "January") )
- title("Average July and January temperatures")
- subtitle("by region and division of the United States")
- note("Source: U.S. Census Bureau, U.S. Dept. of Commerce") ;
- #delimit cr
复制代码 |
| - sysuse citytemp, clear
- #delimit ;
- graph hbar tempjan, over(division) over(region) nofill
- ytitle("Degrees Fahrenheit")
- title("Average January temperature")
- subtitle("by region and division of the United States")
- note("Source: U.S. Census Bureau, U.S. Dept. of Commerce") ;
- #delimit cr
复制代码 |
| - sysuse nlsw88, clear
- #delimit ;
- graph bar wage, over(smsa, descend gap(-30)) over(married)
- over(collgrad, relabel(1 "Not college graduate" 2 "College graduate"))
- ytitle("")
- title("Average Hourly Wage, 1988, Women Aged 34-46")
- subtitle("by College Graduation, Marital Status, and SMSA residence")
- note("Source: 1988 data from NLS, U.S. Dept. of Labor, Bureau of Labor Statistics") ;
- #delimit cr
复制代码 |
| - sysuse educ99gdp, clear
- generate total = private + public
- #delimit ;
- graph hbar (asis) public private,
- over(country, sort(total) descending) stack
- title("Spending on tertiary education as % of GDP, 1999",
- span pos(11))
- subtitle(" ")
- note("Source: OECD, Education at a Glance 2002", span) ;
- #delimit cr
复制代码 |
|
| 混搭不同颜色区别变量
- clear
- input ///
- id w software mark
- 1 1 1 129
- 2 1 2 103
- 3 1 3 171
- 4 1 4 98
- 5 1 5 110
- 6 1 6 13
- 7 1 7 4
- 8 1 8 7
- 9 1 9 49
- 10 1 10 60
- end
- label define kk ///
- 1 "Stata " ///
- 2 "MATLAB®" ///
- 3 "SPSS" ///
- 4 "R" ///
- 5 "EViews" ///
- 6 "Hadoop" ///
- 7 "WinBUGs" ///
- 8 "Gauss " ///
- 9 "Python" ///
- 10 "SAS"
- label value software kk
- label define w 1 "计量经济学与统计软件使用大调查"
- label value w w
- graph bar (asis) mark, over(id) over(software,label(angle(45))) over(w) ///
- ylabel( 0(20)190, angle(45)) ///
- blabel(bar, position(12) format(%9.0f) color(black)) ///
- scheme(s2color) legend(off) ///
- bargap(5) title({bf:万万个论坛币大放送之二} ) subtitle("经管代码库") ///
- nofill ytitle("投票数") ///
- bar(1, color(gold)) ///
- bar(6, color(gold)) ///
- bar(2, color(gs13)) ///
- bar(7, color(gs13)) ///
- bar(3, color(sienna)) ///
- bar(8, color(sienna)) ///
- bar(4, color(cyan)) ///
- bar(9, color(cyan)) ///
- bar(5, color(pink)) ///
- bar(10, color(pink))
复制代码 |
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|
|
-
总评分: 经验 + 100
论坛币 + 100
学术水平 + 5
热心指数 + 5
信用等级 + 5
查看全部评分
|