1、Eviews作图操作Eviews7中的图形操作Wfcreate wfopen wfselect wfstats wfsave 一、图形的分类1.线条图,如errbar、hile、line、spike2.填充图,如area、bar、pie3.XY图,如xy、xyline、xypair、scat4.统计图,如boxplot、cdfplot、hist、distplot kernel、qqplot5.其他对象的特有图形,如方程对象的置信椭圆cellipse图形能方便地实现数据和计量分析结果的可视化。图形对象包含对象的图形视图和图形对象。可以把图象视图定格成图形对象再进行修改。二、创建图形对象图形可以用
2、graph命令创建,也可以从其他对象的图形视图定格而来。如graph gf.line gdp(或graph gf gdp,默认为线条图)用freeze命令把其他对象的图形视图定格成图形对象。如freeze(gf) gdp.linemerge命令是合并已有的图形对象freeze(g1) gdp.lineshow g1graph g2.bar m1show g2graph g3.merge gf ggshow g3多个子图,用align命令设置排列方式,例如Graph gfan.line(m) log(gdp) log(m1) rsGfan.align(2,1.5,1)三、定制图形图形对象可以通过
3、程序修改的部分有:线型(pattern)和填充,图例(legend)和图框(frame),坐标轴,还可以在图形对象上增加文本、线和阴影等。1.图框 使用options命令,例如 graph gf1.line rs Copy gf1 gf2Gf2.options indent(缩进) Copy gf1 gf3 Gf3.options inbox(去掉边框) Copy gf1 gf4 Gf4.options size(8,3)(修改为8,3虚拟英寸) Graph gffr.merge gf1 gf2 gf3 gf4Gffr.legend displayGffr.align(2,1,1)Delete
4、 gf? 2.坐标轴有些图形命令,如line,对多个序列作图时,有如下坐标轴选项:a:自动选择坐标轴,横轴在底部,纵轴在左边。d:双坐标轴,第一个序列对应左边的坐标轴,其他序列对应右边的坐标轴,第一个序列的图形与其他序列不相交。x:同d,但允许相交。n:将序列标准化。例如graph gf1.line rs prcopy gf1 gf2gf2.scale(left) log(采用对数坐标)copy gf1 gf3gf3.setelem(2) axis(right)(将价格水平的坐标放到右边)copy gf3 gf4gf4.scale overlap(允许相交)graph gfas.merge g
5、f1 gf2 gf3 gf4gfas.align(2,2,2)delete gf?show gfas命令scale有invert和range等选项,设置反向坐标轴和坐标轴的标注范围。如Graph gf1.line log(gdp)Copy gf1 gf2Gf2.scale invertCopy gf1 gf3Gf3.scale linearzeroCopy gf1 gf4Gf4.scale range(4,8)Graph gfa1.merge gf1 gf2 gf3 gf4Gfa1.legend displayGfa1.align(2,1,1)Delete gf?Show gfa1坐标的外观,
6、时间标度等也可以进行设置。例如Graph gf1.line log(rs)Copy gf1 gf2Gf2.axis mirror zeroline (增加零线,左右同时给出刻度)Copy gf1 gf3Gf3.datelabel interval(year,10) (横轴刻度是10年)Copy gf1 gf4Gf4.axis label grid ticksin (去掉标度,增加网格线,刻度在里面)Graph gfag.merge gf1 gf2 gf3 gf4Gfag.legend displayGfag.align(2,1,1)Delete gf?Show gfagwfopen hssmp
7、l 1988 lastgraph gf1.line hsshow gf1gf1.datelabel format(yyyy) interval(year,1)gf1.legend -displaycopy gf1 gf2show gf2gf2.datelabel format(yyyy) interval(year,1) -spangraph gf.merge gf1 gf2gf.align(2,1,1)show gf3.颜色和线型wfopen demosmpl 1990 lastgraph gf1.line gdp m1copy gf1 gf2show gf2gf2.setelem(2) l
8、color(orange) lwidth(2) copy gf1 gf3show gf3gf3.setelem(1) lpat(dash1) symbol(star)copy gf3 gf4show gf4gf4.options -color Graph gf1c.merge gf1 gf2 gf3 gf4Gf1c.align(2,1,1)Delete gf?Smpl allShow gf1c4.填充和纹线matrix(2,3) mmmm.fill 1,5,3,4,6,2show mmfreeze(gf1) mm.barshow gf1Copy gf1 gf2Gf2.options color
9、show gf2gf2.options -colorcopy gf1 gf3gf3.setelem(1) gray(5) hatch(7)gf3.setelem(2) gray(1) hatch(3)gf3.setelem(3) gray(3) hatch(4)copy gf3 gf4show gf4gf4.options -colorgraph gff.merge gf1 gf2 gf3 gf4gff.align(2,2,2)show gff5.标注可以用addtext命令在图形中添加文字,用draw命令突出某些内容。例如graph gf1.line rsshow rsclose rs sh
10、ow gf1copy gf1 gf2gf1.addtext(t) short trem interest rategf1.addtext(l) percentshow gf2gf2.draw(shade,bottom,rgb(235,200,180) 80 85gf2.draw(dashline,left,color(red) 8graph gfat.merge gf1 gf2gfat.align(2,1,1)gfat.legend -displayshow gfat6.图例可以控制图例的位置、文本和外观。graph gf1.line log(gdp) log(m1) pr rsshow gf
11、1gf1.name(3) Price Levelcopy gf1 gf2gf2.legend -inbox position(0.4,0.5) columns(1)gf2.name(4)graph gfag.merge gf1 gf2gfag.align(2,2,2)show gfaggfag.legend font(20) 设置字体gfag.legend display 不要图例四、图形模板通过模板,可以复制图形类型、线型和填充的设置、坐标轴的标度方式、图例的各种属性和图框的各种设定等。graph gf0.line log(gdp) log(m1)show gf0gf0.setelem(1)
12、 lwidth(4)gf0.setelem(2) symbol(1)gf0.draw(shade,bottom) 80 85graph gf1.line(o=gf0) pr*10 rsshow gf1graph gf2.line(t=gf0) pr*10 rsshow gf2还可以在图形创建后再应用模板,例如Graph gf1.line pr*10 rsGf1.template(o) gf0Graph gf2.line pr*10 rsGf2.template(t) gf0五、打印和导出保存成图形文件。Save命令支持三种常用的矢量图形文件,分别是wmf文件、emf文件、eps文件。例如gf2
13、.save(t=wmf,u=in,w=4,-c) mygf命令名:freezegraphsavemergealigntemplateoptionsnameaddtextlegend draw scalesetelem直方图x.distplot hist关键字hist为命令distplot的分析设定(analytical spec)。hist有自己的选项。标度类型:scale=dens,freq,relfreg,分别表示密度直方图、频数直方图(默认)和频率直方图。柱宽:binw=eviews,sigma,iqr,silverman,freefman.锚点:anchor=num分界点:rightc
14、losed图例文字:leg=def,n,s,det,默认给出最少信息,其他三个选项对应的图例文字信息分别为无文本、短文本和详细信息。折现直方图:distplot freqpoly边线直方图:distplot edgefreqpoly移位直方图:distplot ashwfopen demogdp.histfreeze(gf01) gdp.distplot freqpolyshow gf01Freeze(gf02) gdp.distplot edgefreqpoly(fill)show gf02freeze(gf03) gdp.distplot hist ashshow gf03freeze(g
15、f04)gdp.distplot hist(binw=silverman,anchor=0.6) ashshow gf04增加正态分布曲线:选中要画图的序列,打开,点view/gragh 在specific里选中distribution,右边的distribution框选择histogram。点击右边的option,在弹出来的框里点add,弹出的add框里选Theoretical Density。点击ok 再点击ok。最后点击ok。经验分布函数图Eviews5 cdfplotEviews7 distplot cdfDistplot cdf命令,默认绘制累积分布函数函数(选项c),还支持生存函数
16、(选项s)和分位数函数(选项q)。例如lnwage.distplot cdf (说明:shows the cumulative distribution plot for lnwage, along with the default 95% confidence intervals. )lnwage.distplot cdf(noci)则是不显示95%的置信区间lnwage.distplot survivor(noci) group gro1 weight height gro1.distplot logsurvivor(ci=0.9, leg=det) (说明displays the log
17、-survivor plots for WEIGHT and HEIGHT along with 90% confidence intervals, and a detailed legend. The plots will be displayed in individual graph frames. )gro1.distplot(s) quantile (说明shows the quantile plots for WEIGHT and HEIGHT in the same graph frame. )QQ图比较两个分布的工具。如果分布相同,QQ图应该是一条直线。理论QQ图(正态分布n,
18、均匀分布u,指数分布e,Logistic分布l,第一类极值分布x),经验QQ图(s=name).series wage=exp(lnwage)group w wage log(wage)freeze(gfw) w.qqplot(n)show gfwgfw.align(2,1,1) wfopen demorndseed(type=mt) 12357group dist rnorm rchisq(5)freeze(gf) rs.qqplot(s=dist) show gfgf.align(2,1,1)直接比较PDF.如何绘制序列和某种分布的PDF?Do rs.distplot kernel(obs
19、range,b=3,o=mrs)series xseries rskgroup g x rskmtos(mrs,g)genr y=dchisq(x,5)y.displayname chi-squre(5)rsk.displayname interest rategraph gfd.xyline x y rskshow gfdgfd.legend -inbox position(2.4,0.2) columns(1)盒图wfopen garchgroup g raaa r3freeze(gfb) g.boxplot show gfb产生盒图的命令中,boxplot 是群对象命令,进行多个序列的盒
20、图比较。而boxplotby是序列对象的命令,绘制单个序列内不同分组的盒图。修改盒图元素的命令为setbpelem.例如Copy gfb gfnGfn.setbpelem ci(notch)将盒图中间的阴影部分改为凹槽。Syntax语法boxplot(options) o1 o2 o3 . object_name.boxplot(options) categorical_spec(arg) where o1, o2, ., are series or group objects. You may specify general options after the boxplot keyword
21、. The optional categorical_spec allows you to specify a categorical graph (see Categorical Spec). Options q=arg Set the quantile method, where arg can be: r - Rankit-Cleveland, o - Ordinary, v - van der Waerden, b - Blom, t - Tukey, g - Gumbel. rotate Rotate the graph so the observation axis is on t
22、he left. Multiple series options (categorical graph settings will override these options) m Plot boxplots in multiple graphs. Panel options The following option applies when graphing panel structured data: panel=arg (default taken from global settings) Panel data display: stack (stack the cross-sect
23、ions), individual or i (separate graph for each cross-section), combine or c (compute cross-section graphs in a single frame). (Note: more general versions of these panel graphs may be constructed as categorical graphs.) Examples Basic examples wage.boxplot displays boxplots for the series WAGE. gro
24、up g1 wage sex race g1.boxplot displays boxplots for WAGES, SEX and RACE in a single graph frame. g1.boxplot(m, rotate) places the rotated boxplots for each series in a separate frame. Panel examples ser1.boxplot(panel=individual) displays boxplots for each cross-section in a separate frame, while,
25、ser1.boxplot(panel=stack) displays a single boxplot computed from the stacked panel data. ser1.boxplot(panel=combined, rotate) shows rotated boxplots computed for each period (across cross-sections) in a single frame. Categorical spec examples ser1.boxplot across(firm, dispname) displays a categoric
26、al boxplot graph of SER1 using distinct values of FIRM to define the categories, and displaying the resulting graphs in multiple frames with common scaling. Each frame is labeled using the FIRM display name. ser1.boxplot across(firm, dispname, iscale) constructs the same graph with individual scalin
27、g. ser1.boxplot within(firm, label=value) constructs a boxplot for each value of FIRM and displays the results in a single frame. The individual boxplots are labeled using the value of FIRM associated with the category. ser1.boxplot across(firm) within(income, bintype=quant, bincount=4) constructs a
28、 categorical boxplot with FIRM defining the across dimension, and INCOME defining the within dimension. Boxplots for each INCOME quartile of a given firm will be contained in a single frame, with different firms displayed in different frames. grp1.boxplot within(sex) within(union) creates an boxplot
29、 for within categories based on both SEX and UNION. Since we have not specified behavior for the implicit SERIES in GRP1, each series in the group will be displayed in a separate frame, with individual scaling. graph_name.setbpelem element_list The element_list may contain one or more of the followi
30、ng: median, med / -median, -med Show / Do not show the medians. mean / -mean Show / Do not show the means. whiskers, w / -whiskers, -w Show / Do not show the whiskers (lines from the box to the staples). staples, s / -staples, -s Show / Do not show the staples (lines drawn at the last data point within the inner fences). near / -near Show /Do not show the near outliers (values between the inner and outer fences). far / -far Show / Do not show the far outliers (values beyond the outer fences). width(arg) (default =fixed)
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1