上机实验10:Eviews7中的图形操作
area area graph.
band area band graph.
bar bar graph.
boxplot boxplot graph.
distplot distribution graph.
dot dot plot graph.
errbar error bar graph.
hilo high-low(-open-close) graph.
line line-symbol graph.
pie pie chart.
qqplot quantile-quantile graph .
scat scatterplot.
scatmat matrix of scatterplots.
scatpair scatterplot pairs graph.
seasplot seasonal line graph.
spike spike graph.
xyarea XY area graph.
xybar XY bar graph.
xyline XY line graph.
xypair XY pairs graph.
一、图形的分类
1.线条图,如errbar、hile、line、spike
2.填充图,如area、bar、pie
3.XY图,如xy、xyline、xypair、scat
4.统计图,如boxplot、cdfplot、hist、distplot kernel、qqplot
5.其他对象的特有图形,如方程对象的置信椭圆cellipse
图形能方便地实现数据和计量分析结果的可视化。图形对象包含对象的图形视图和图形对象。可
以把图象视图定格成图形对象再进行修改。
二、创建图形对象
打开Eviews7,打开demo.wf1文件。
图形可以用graph命令创建,也可以从其他对象的图形视图定格而来。
如graph gf.line gdp (或graph gf gdp,默认为线条图)
用freeze命令把其他对象的图形视图定格成图形对象。
如freeze(gf) gdp.line
merge命令是合并已有的图形对象
freeze(g1) gdp.line
show g1
graph g2.bar m1
show g2
graph g3.merge gf gg
show g3
多个子图,用align命令设置排列方式,例如
Graph gfan.line(m) log(gdp) log(m1) rs
Gfan.align(2,1.5,1)
LOG(GDP)87.26.876.466.05.655.2455606570758085909.8556065707580859095LOG(M1)RS1612840556065707580859095
三、定制图形
图形对象可以通过程序修改的部分有:线型(pattern)和填充,图例(legend)和图框(frame),坐标轴,还可以在图形对象上增加文本、线和阴影等。
1.图框 使用options命令,例如
graph gf1.line rs
Copy gf1 gf2
Gf2.options indent(缩进)
Copy gf1 gf3
Gf3.options –inbox(去掉边框)
Copy gf1 gf4
Gf4.options size(8,3)(修改为8,3虚拟英寸)Graph gffr.merge gf1 gf2 gf3 gf4
Gffr.legend –display
Gffr.align(2,1,1)
Delete gf?
RS16141210820195519601965197019751980198519901995RS161412108201955196019651970197519801985199019952.坐标轴
RS16141210820195519601965197019751980198519901995RS161412108205256586062666870727476788082848680929496
有些图形命令,如line,对多个序列作图时,有如下坐标轴选项:
a:自动选择坐标轴,横轴在底部,纵轴在左边。
d:双坐标轴,第一个序列对应左边的坐标轴,其他序列对应右边的坐标轴,第一个序列的图形与其他序列不相交。
x:同d,但允许相交。
n:将序列标准化。
例如
graph gf1.line rs pr
copy gf1 gf2
gf2.scale(left) log(采用对数坐标)
copy gf1 gf3
gf3.setelem(2) axis(right)(将价格水平的坐标放到右边)
copy gf3 gf4
gf4.scale overlap(允许相交)
graph gfas.merge gf1 gf2 gf3 gf4
gfas.align(2,2,2)
delete gf?
show gfas
1614121082019551960196519701975RS1980PR1985199019951.00.70.50.30.20.119551960196519701975RS1980PR19851990199520.010.07.05.03.02.01.21.00.8160.60.40.280.01614121081242019551960196519701975RS1980PR19851990199519551960196519701975RS1980PR1985199019950
命令scale有invert和range等选项,设置反向坐标轴和坐标轴的标注范围。如
Graph gf1.line log(gdp)
Copy gf1 gf2
Gf2.scale invert
Copy gf1 gf3
Gf3.scale linearzero
Copy gf1 gf4
Gf4.scale range(4,8)
Graph gfa1.merge gf1 gf2 gf3 gf4
Gfa1.legend –display
Gfa1.align(2,1,1)
Delete gf?
Show gfa1
LOG(GDP)7.67.26.86.46.05.65.24.84.419551960196519701975198019851990199.44.85.25.66.06.46.87.27.6195519601965197019751980198519901995LOG(GDP)LOG(GDP)87632101955196019651970197519801985199019958.07.57.06.56.05.55.04..0195519601965LOG(GDP)197019751980198519901995 坐标的外观,时间标度等也可以进行设置。例如
Graph gf1.line log(rs)
Copy gf1 gf2
Gf2.axis mirror zeroline (增加零线,左右同时给出刻度)
Copy gf1 gf3
Gf3.datelabel interval(year,10) (横轴刻度是10年)
Copy gf1 gf4
Gf4.axis –label grid ticksin (去掉标度,增加网格线,刻度在里面)
Graph gfag.merge gf1 gf2 gf3 gf4
Gfag.legend –display
Gfag.align(2,1,1)
Delete gf?
Show gfag
LOG(RS)2.82.42.01.61.20.80.40.0-0.4195519601965197019751980198519901995LOG(RS)2.82.42.01.61.20.80.40.0-0.41960197019801990再打开Eviews7,打开hs.wf1文件
smpl 1988 @last
LOG(RS)2.82.82.42.42.02.01.61.61.21.20.80.80.40.40.00.0-0.4-0.4195519601965197019751980198519901995LOG(RS)
graph gf1.line hs
show gf1
gf1.datelabel format(yyyy) interval(year,1)
gf1.legend -display
copy gf1 gf2
show gf2
gf2.datelabel format(yyyy) interval(year,1) -span
graph gf.merge gf1 gf2
gf.align(2,1,1)
show gf
Housing Starts160160Housing Starts1401401201201001008080606040198819199019911992401988191990199119923.颜色和线型
wfopen demo
smpl 1990 @last
graph gf1.line gdp m1
copy gf1 gf2
show gf2
gf2.setelem(2) lcolor(orange) lwidth(2)
2,0001,8001,6001,4001,2001,0008001990199119921993GDP1994M119951996
copy gf1 gf3
show gf3
gf3.setelem(1) lpat(dash1) symbol(star)
2,0001,8001,6001,4001,2001,0008001990199119921993GDP1994M119951996
copy gf3 gf4
show gf4
gf4.options -color
2,0001,8001,6001,4001,2001,0008001990199119921993GDP1994M119951996
Graph gf1c.merge gf1 gf2 gf3 gf4
Gf1c.align(2,1,1)
Delete gf?
Smpl @all
Show gf1c
2,0002,0001,8001,8001,6001,6001,4001,4001,2001,2001,0001,000800IIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIV1990199119921993GDP2,0001994M119951996800IIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIV1990199119921993GDP2,0001994M1199519961,8001,8001,6001,6001,4001,4001,2001,2001,0001,000800IIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIV1990199119921993GDP1994M119951996800IIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIVIIIIIIIV1990199119921993GDP1994M119951996
也可以通过在图形上点击右键,修改图形。
4.填充和纹线
matrix(2,3) mm
mm.fill 1,5,3,4,6,2
show mm
freeze(gf1) mm.bar
show gf1
7632101C1C2C32
Copy gf1 gf2
Gf2.options –color
show gf2
gf2.options -color
copy gf1 gf3
gf3.setelem(1) gray(5) hatch(7)
gf3.setelem(2) gray(1) hatch(3)
gf3.setelem(3) gray(3) hatch(4)
copy gf3 gf4
show gf4
gf4.options -color
graph gff.merge gf1 gf2 gf3 gf4
gff.align(2,2,2)
show gff
76321012C1C2C376321012C1C2C35.标注
76321012C1C2C376321012C1C2C3
可以用addtext命令在图形中添加文字,用draw命令突出某些内容。例如graph gf1.line rs
show rs
close rs
show gf1
copy gf1 gf2
gf1.addtext(t) \"short trem interest rate\"
gf1.addtext(l) \"percent\"
show gf2
gf2.draw(shade,bottom,rgb(235,200,180)) 80 85
gf2.draw(dashline,left,color(red)) 8
graph gfat.merge gf1 gf2
gfat.align(2,1,1)
gfat.legend -display
show gfat
short trem interest rate1614121016141210820195519601965197019751980198519901995195519601965197019751980198519901995RSpercent820 6.图例
可以控制图例的位置、文本和外观。
graph gf1.line log(gdp) log(m1) pr rs
show gf1
gf1.name(3) Price Level
copy gf1 gf2
gf2.legend -inbox position(0.4,0.5) columns(1)
gf2.name(4)
graph gfag.merge gf1 gf2
gfag.align(2,2,2)
show gfag
1614121082019551960196519701975198019851990199516141210820195519601965197019751980198519901995LOG(GDP)LOG(M1)Price LevelLOG(GDP)Price LevelLOG(M1)RS
gfag.legend font(20) 设置字体
gfag.legend –display 不要图例
四、图形模板
通过模板,可以复制图形类型、线型和填充的设置、坐标轴的标度方式、图例的各种属性和图框的各种设定等。
graph gf0.line log(gdp) log(m1)
show gf0
gf0.setelem(1) lwidth(4)
gf0.setelem(2) symbol(1)
gf0.draw(shade,bottom) 80 85
7.67.26.86.46.05.65.24.84.4195519601965197019751980LOG(M1)198519901995LOG(GDP)
graph gf1.line(o=gf0) pr*10 rs
show gf1
16141210820195519601965197019751980RS198519901995PR*10
graph gf2.line(t=gf0) pr*10 rs
show gf2
16141210820195519601965197019751980RS198519901995PR*10
还可以在图形创建后再应用模板,例如
Graph gf1.line pr*10 rs
Gf1.template(o) gf0
Graph gf2.line pr*10 rs
Gf2.template(t) gf0
五、打印和导出
保存成图形文件。Save命令支持三种常用的矢量图形文件,分别是wmf文件、emf文件、eps文件。例如
gf2.save(t=wmf,u=in,w=4,-c) mygf
命令名:freeze\\graph\\save\\merge\\align\emplate\\options\\name\\addtext\\legend\\ draw \\scale\\setelem
直方图
x.distplot hist
关键字hist为命令distplot的分析设定(analytical spec)。hist有自己的选项。
标度类型:scale={dens,freq,relfreg},分别表示密度直方图、频数直方图(默认)和频率直方图。
柱宽:binw={eviews,sigma,iqr,silverman,freefman}.
锚点:anchor=num
分界点:rightclosed
图例文字:leg={def,n,s,det},默认给出最少信息,其他三个选项对应的图例文字信息分别为无文本、短文本和详细信息。
折线直方图:distplot freqpoly
边线直方图:distplot edgefreqpoly
移位直方图:distplot ash
wfopen demo
gdp.hist
3530252015105020040060080010001200140016001800Series: GDPSample 1952Q1 1996Q4Observations 180Mean Median Maximum Minimum Std. Dev. Skewness Kurtosis Jarque-BeraProbability 632.4190 374.3000 1948.225 87.87500 5.2441 0.845880 2.345008 24.68300 0.000004 freeze(gf01) gdp.distplot freqpoly
show gf01
GDP353025Frequency2015105002004006008001,0001,2001,4001,6001,8002,000
Freeze(gf02) gdp.distplot edgefreqpoly(fill)
show gf02
GDP242016Frequency1284002004006008001,0001,2001,4001,6001,8002,000
freeze(gf03) gdp.distplot hist ash
show gf03
GDP353025Frequency2015105002004006008001,0001,2001,4001,6001,8002,0002,200HistogramASH
freeze(gf04)gdp.distplot hist(binw=silverman,anchor=0.6) ash
show gf04
GDP8070605040302010002004006008001,0001,2001,4001,6001,8002,0002,200HistogramASHFrequency
增加正态分布曲线:
选中要画图的序列,打开,点view/gragh 在specific里选中distribution,右边的distribution框选择histogram。点击右边的option,在弹出来的框里点add,弹出的add框里选Theoretical Density。点击ok 再点击ok。最后点击ok。
图形右键的图选项:
View中图选项:
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- haog.cn 版权所有 赣ICP备2024042798号-2
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务