by sxlion
SAS绘图即学即用系列连载4.1 –曲线图: 以下代码 可以拷贝到SAS编辑器中,直接使用;稍作更改便可得到自己满意的图形。以下来自一本关于SAS绘图的书稿(未出版草稿),均为本人原创。 完整代码详见SAS资源资讯列表 www.saslist.net
4.1 线图
4.11 曲线图
1 2 3 4 5 6 7 8 9 | FILENAME file "d:\SAS_charts\sample411.png"; goptions reset=all device=png gsfname=file/*设置图片格式和存放点*/ hsize=8cm vsize=6cm ; /* 设置绘图区域大小 */ symbol value=none interpol=j CI=orange width=3; /* 设置线点属性 */ proc gplot data=sashelp.stocks; plot high*date; where stock="IBM" and ('01feb90'd <= date <= '01feb91'd); run; quit; |
4.12 分组曲线图
1 2 3 4 5 6 7 8 9 10 11 | FILENAME file "d:\SAS_charts\sample413.png"; goptions reset=all device=png gsfname=file/*设置图片格式和存放点*/ hsize=8cm vsize=6cm ; /* 设置绘图区域大小 */ symbol1 value=none interpol=join CI=red width=2; symbol2 value=none interpol=join CI=blue width=2; symbol3 value=none interpol=join CI=orange width=2; proc gplot data=sashelp.stocks; plot high*date=stock; where ('01feb90'd < date < '01feb91'd); run; quit; |
4.13 双/多曲线图
1 2 3 4 5 6 7 8 9 10 11 | FILENAME file "d:\SAS_charts\sample414.png"; goptions reset=all device=png gsfname=file/*设置图片格式和存放点*/ hsize=10cm vsize=8cm ; /* 设置绘图区域大小 */ symbol1 value=none interpol=join CI=red L=2 width=1; /*L:设置线型 */ symbol2 value=none interpol=join CI=orange L=1 width=2; symbol3 value=none interpol=join CI=green L=3 width=1; proc gplot data=sashelp.stocks; plot high*date close *date low*date /overlay ; where stock="IBM" and ('01feb90'd < date < '01feb91'd); run; quit; |
4.14 双坐标曲线图
1 2 3 4 5 6 7 8 9 10 11 | FILENAME file "d:\SAS_charts\sample415.png"; goptions reset=all device=png gsfname=file/*设置图片格式和存放点*/ hsize=10cm vsize=8cm ; /* 设置绘图区域大小 */ symbol value=none interpol=j CI=red width=1; /* 设置线属性 */ symbol2 value=none interpol=j CI=black width=1; /* 设置点属性 */ proc gplot data=sashelp.stocks; plot high*date/vzero; plot2 volume*date; where stock="IBM" and ('01feb90'd <= date <= '01feb91'd); run; quit; |
4.15 其他修饰:
参考线、图例、坐标轴、标题、脚注
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | FILENAME file "d:\SAS_charts\sample416.png"; goptions reset=all device=png gsfname=file/*设置图片格式和存放点*/ hsize=12cm vsize=8cm ; /* 设置绘图区域大小 */ symbol1 value=none interpol=join CI=red width=2;/* 设置点属性 */ symbol2 value=none interpol=join CI=orange width=2; symbol3 value=none interpol=join CI=green width=2; axis1 order= ('01jan86'd to '01jan06'd by 1461) LABEL=( "Period") minor=none offset=(0.2 cm); /*调整坐标轴的显示、改变轴标签内容*/ axis2 order= (0 to 250 by 50) LABEL=(angle=90 "") major=none minor=none; /*调整坐标轴的显示、改变轴标签内容和位置*/ legend1 label=none position=(top right inside) mode=share; Title H=0.4cm "Three company's stock from '01JAN86' to '01JAN06' "; Footnote justify=left "Data resource: sashelp.stocks" ; proc gplot data=sashelp.stocks; plot close*date=stock / haxis=axis1 vaxis=axis2 vref=50 to 200 by 50 lvref=1 CVREF=black WVREF=1 legend=legend1 ; run; quit; |
原创文章: ”SAS绘图即学即用系列连载4.1-线图“,转载请注明: 转自SAS资源资讯列表
本文链接地址: http://saslist.net/archives/409