楼主: BraveMadMan
5949 35

[程序分享] 如何生成这个图 [推广有奖]

  • 1关注
  • 6粉丝

已卖:97份资源

讲师

16%

还不是VIP/贵宾

-

威望
0
论坛币
966 个
通用积分
6.3763
学术水平
26 点
热心指数
42 点
信用等级
10 点
经验
7812 点
帖子
300
精华
0
在线时间
552 小时
注册时间
2005-8-11
最后登录
2021-5-20

楼主
BraveMadMan 发表于 2010-7-12 17:00:19 |AI写论文
100论坛币
如何从“现有的图”做成“想要的图”。

想要的图:

figx1.png


现有的图:

figx2.PNG


具体要求:
1、修改“现有的图”的横坐标
2、修改“现有的图”的两个纵坐标

现有的数据:
stat_qtr1.rar (5.5 KB) 本附件包括:
  • stat_qtr1.sas7bdat


现有的作图程序:
proc sgplot data=stat_qtr1 NOAUTOLEGEND;
   vline yqtr / response=all y2axis;
   vbar yqtr / response=p_pos TRANSPARENCY=0;
   vbar yqtr / response=p_neg TRANSPARENCY=0;
   format yqtr yyqc4.;
   xaxis values=('1jan72'd to '1jul07'd by year) label = "Year";
   yaxis label="Percentage" ;
   y2axis  label="# of observations" ;
run;
quit;
quit;


根据jingju11 提供的程序最后生成的结果


100713232114cd7b8edfa1cdbc[1].png
  1. title;
  2. proc format;
  3. value yfmt -5000 = ' ' 0-5000 = [best7.] ;
  4. value pfmt -15 - 15 = [best7.] 35 = ' ';
  5. run;
  6. proc sgplot data=stat_qtr1 NOAUTOLEGEND;
  7. needle x =yqtr y =p_pos/baseline =0 lineattrs =(color =blue thickness =3) ;
  8. needle x =yqtr y =p_neg/baseline =0 lineattrs =(color =red thickness =3);
  9. series x =yqtr y =all/y2axis lineattrs =(color =green thickness =2) ;
  10.   format yqtr year2. all yfmt. p_pos pfmt. p_neg pfmt.;
  11. xaxis label = "Year";
  12. yaxis grid values =(-15 to 15 by 10 35)   label="Percentage" ;
  13. y2axis grid values =(-5000 0 to 5000 by 1000) label="# of observations" ;
  14. run; quit;
复制代码

最佳答案

jingju11 查看完整内容

19# BraveMadMan
关键词:observations Transparency observation percentage response values 如何 程序

沙发
jingju11 发表于 2010-7-12 17:00:20
19# BraveMadMan
  1. title;
  2. proc format;
  3. value Yfmt -5000 = ' ' 0-5000 = [best.];
  4. run;
  5. proc sgplot data=tmp1.stat_qtr1 NOAUTOLEGEND;
  6. needle x =yqtr y =p_pos/baseline =0 lineattrs =(color =blue thickness =3);
  7. needle x =yqtr y =p_neg/baseline =0 lineattrs =(color =red thickness =3);
  8. series x =yqtr y =all/y2axis lineattrs =(color =green thickness =2);;
  9.   format yqtr year2. all Yfmt.;
  10. xaxis label = "Year"; yaxis label="Percentage" ;
  11. y2axis grid values =(-5000 0 to 5000 by 1000) label="# of observations" ;
  12. run; quit;
复制代码
untitled.PNG
已有 3 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
crackman + 1 + 1 值得学习
peijiamei + 100 + 1 精彩帖子
BraveMadMan + 1 + 1 + 1 我很赞同

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

藤椅
BraveMadMan 发表于 2010-7-13 06:42:48
增加到100论坛币

板凳
jingju11 发表于 2010-7-13 10:31:33
2# Brav
adMan


对于我来讲,很难。都用的是discrete axis。不知道有什么方法有选择性地标注x轴的数据。

报纸
soporaeternus 发表于 2010-7-13 10:41:09
楼主是一次性画一个图一定要有这个效果,还是需要一个制图模板,以后会定期更新数据啊?
太复杂的图,proc ganno或许可以试试
Let them be hard, but never unjust

地板
platypus 发表于 2010-7-13 10:42:05
这个SAS应该很难一次性输出,可以后期使用sigmaplot修改下,具体的可参考刘万祥老师的《图表之道??》
机会稍纵即逝,且只给有准备的人。

7
BraveMadMan 发表于 2010-7-13 10:46:00
soporaeternus 发表于 2010-7-13 10:41
楼主是一次性画一个图一定要有这个效果,还是需要一个制图模板,以后会定期更新数据啊?
太复杂的图,proc ganno或许可以试试
这个图是一次性的。不过我经常碰到要划类似图的情况。

8
蓝色 发表于 2010-7-13 10:50:09
第一个图是stata 做的图吧

9
BraveMadMan 发表于 2010-7-13 10:51:17
蓝色 发表于 2010-7-13 10:50
第一个图是stata 做的图吧
敏锐。是stata 做的图

10
BraveMadMan 发表于 2010-7-13 10:53:04
我想到一个让两个纵坐标错开的办法,不过应该有更好的办法。

proc sgplot data=stat_qtr1 NOAUTOLEGEND;
   vline  yqtr / response=all y2axis;
   vbar yqtr / response=p_pos TRANSPARENCY=0;
   vbar yqtr / response=p_neg TRANSPARENCY=0;
   format yqtr yyqc4.;
   xaxis values=('1jan00'd to '1jul07'd by year) label = "Year";
   yaxis min=-15 max=30 label="Percentage" ;
   y2axis min =-4000 label="# of observations" ;
run;
quit;
quit;


效果图:
fig3.PNG

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-25 13:34