楼主: zlqs1985
14169 26

[作图问题求助] Stata作图的能力实在是不敢恭维(以横轴日期显示为例) [推广有奖]

11
zlqs1985 发表于 2015-11-26 20:56:58
蓝色 发表于 2015-11-26 19:41
你如果不想显示时间
只需要设置
format  date  %9.0f
   问题是,还是想显示时间啊,比如说固定显示每一年的1月份和7月份,写成xlabel(2006m1(6)2014m12)肯定是不行的,那就需要手工(或者近似手工的用--forval--)寻找到每一个月份对应的elapsed time value, 在我的例子中就是
552 558 564 570 576 582 588 594 600 606 612 618 624 630 636 642 648 654
   这一堆怪怪的数字,然后手工输入到xlabel选项中,我觉得这个过程极其蛋疼。

12
蓝色 发表于 2015-11-26 20:59:48
zlqs1985 发表于 2015-11-26 20:56
问题是,还是想显示时间啊,比如说固定显示每一年的1月份和7月份,写成xlabel(2006m1(6)2014m12)肯定 ...
我给你的链接
和程序上的例子,很明显直接就显示
不需要xlabel

format date %tm
就可以啊

13
zlqs1985 发表于 2015-11-26 21:01:58
蓝色 发表于 2015-11-26 20:59
我给你的链接
和程序上的例子,很明显直接就显示
不需要xlabel
如果只想显示特定的月份呢?我的时间变量已经format 了
时间变量
我的code

twoway (line new70_index time2)(line CREIS100_hpi time2) ///
  ,                                                      ///
   xlabel(552 558 564 570 576 582 588 594 600 606 612 618 624 630 636 642 648 654   ///
   ,angle(45)) ///
   title("住宅价格指数(全国)")                           ///
   ytitle("月度数据,基期为2005年7月")                   ///
   xtitle("")                                            ///
   legend (label(1 "NBS70个大中城市房价指数") label(2 "百城住宅价格指数") ///
   region(lcolor(white)) col(1) size(small) position(6) ring(0))

14
蓝色 发表于 2015-11-26 21:11:17
clear
input ///
str10 date y
"1960m1" 1
"1960m2" 1.3
"1960m3" 3.5
"1960m4" 4
"1960m5" 4
end

gen ym=monthly(date,"YM")
list
tw (line y ym),saving(f1,replace)


format ym %tm
tw (line y ym),saving(f2,replace)

graph combine f1.gph f2.gph

15
蓝色 发表于 2015-11-26 21:12:24
clear
input ///
str10 date y
"1960m1" 1
"1960m2" 1.3
"1960m3" 3.5
"1960m4" 4
"1960m5" 4
end

gen ym=monthly(date,"YM")
list
tw (line y ym),saving(f1,replace)


format ym %tm
tw (line y ym),saving(f2,replace)

graph combine f1.gph f2.gph

16
蓝色 发表于 2015-11-26 21:16:01
templq.jpg
clear
input ///
str10 date y
"1960m1" 1
"1960m2" 1.3
"1960m3" 3.5
"1960m4" 4
"1960m5" 4
end

gen ym=monthly(date,"YM")
list
tw (line y ym),saving(f1,replace)


format ym %tm
tw (line y ym),saving(f2,replace)

graph combine f1.gph f2.gph

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
txje + 3 + 3 + 3 热心帮助其他会员

总评分: 学术水平 + 3  热心指数 + 3  信用等级 + 3   查看全部评分

17
BlackHawk123 在职认证  发表于 2015-11-27 23:23:45
Brewing color schemes in Stata:Making it easier for end users to customize Stata graphs
_
  1. *ssc inst brewscheme
  2. brewscheme, scheme(myriadColorPalettes) barst(paired) ///
  3. barc(12) dotst(prgn) dotc(7) scatstyle(set1) scatc(9) ///
  4. linest(pastel2) linec(8) boxstyle(accent) boxc(8) ///
  5. areast(dark2) areac(8) piest(mdepoint) sunst(greys) ///
  6. histst(veggiese) cist(activitiesa) matst(spectral) ///
  7. reflst(purd) refmst(set3) const(ylgn) cone(puor)


  8. sysuse nlsw88.dta, clear
  9. #d;
  10. tw scatter wage ttl_exp if industry == 11 || scatter wage
  11. ttl_exp if industry == 4 || scatter wage ttl_exp if
  12. industry == 6 || scatter wage ttl_exp if industry == 7,
  13. ti("Not so Simple Scatterplot")
  14. scheme(myriadColorPalettes) legend(label(1
  15. "Professional") label(2 "Manufacturing") label(3
  16. "Wholesale/Retail") label(4 "Fin./Insure/Real Estate"));
  17. #d cr
复制代码
Graph.png

18
BlackHawk123 在职认证  发表于 2015-11-28 00:20:30 来自手机
Compared to the graphs that R can do,the main impediment is probably that stata graphics is not programmable by MOST USERS!!!

19
zlqs1985 发表于 2015-11-28 19:01:16
@蓝色 @BlackHawk123  多谢二位的回复

20
niuniuyiwan 在职认证  发表于 2015-11-30 09:56:48
  1. clear
  2. input ///
  3. str10 date   y
  4.         "1960m1" 1
  5.         "1960m2" 1.3
  6.         "1960m3" 3.5
  7.         "1960m4" 4
  8.         "1960m5" 4
  9. end

  10. encode date,gen(t)

  11. tw connected y t, xtick(0(1)5 ,grid glcolor(gs12) glw(*.5) ///
  12.         tlength(*1.5)) xlabel(0.5(1)4.5, noticks format(%tm)) xtitle("") ///
  13.         yla(, ang(h)) saving(f2, asis replace)
复制代码

Graph.png



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

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