第七讲stata作图Stata中的图形种类graphtwoway二维图scatter散点图line折线图area区域图lfit线性拟合图qfit非线性拟合图histogram直方图kdensity密度函数图function函数图graphmatrix矩阵图graphbox箱型图graphdot点图graphbar条形图graphpie饼图二维图命令的基本结构twoway(单元图1)(单元图2),选项1选项2几种常见的图形示例:sysusesp500,clear1.散点图twowayscatterhighdate2.折线图twowaylinechangedate3.柱状图twowaybaropendatein1/504.直方图histogramchange5.密度函数图kdensityclose,normal图形管理图形保存第一种方式sysusesp500,cleartwowaylinehighdategraphsavefig1.gph,replacegraphusefig1.gph第二种方式twowaylinehighdate,saving(price.gph,replace)手动方式右键-savegraph..图形调用graphusefig1.gph坐标轴刻度及刻度标签坐标轴刻度(tick)与刻度标签(label)sysuseauto,clearscattermpgweight,xlabel(#10)scattermpgweight,///ylabel(10(5)45)///xlabel(150020003000400045005000)scattermpgweight,ymlabel(##5)xmtick(##10)scattermpgweight,xlabel(150025003190“中位数”35004500)坐标轴刻度及刻度标签刻度及标签主刻度及标签:ylabel(),xlabel()主刻度:ytick(),xtick()子刻度及标签:ymlabel(),xmlabel()子刻度:ymtick(),xmtick()参数设定规则#4设定4个最佳值##1010-1=9个子刻度列印于住刻度之间10(5)45在10到45范围内,每隔5列印一个子刻度坐标轴标题ytitle(),xtitle()scattermpgweight,ytitle(“汽车里数”,place(top))///xtitle(“汽车重量”,place(right))scattermpgweight,xtitle(“汽车里数”“(mpg)”)坐标结构yscale(),xscale()显示范围的控制:scattermpgweight,xscale(range(05000))xlabel(0(1000)5000)坐标轴的显示不显示坐标轴scattermpgweight,yscale(noline)xscale(noline)不显示坐标轴和刻度标签scattermpgweight,yscale(off)xscale(off)双坐标系共用X轴sysusesp500,cleartwowaylineclosechangedatetwoway(lineclosedate,yaxis(1))///(linechangedate,yaxis(2))twoway(lineclosedate,yaxis(1))///(linechangedate,yaxis(2)),///ylabel(-50(10)40)单独的y轴和x轴twoway(lineclosedate,yaxis(1)xaxis(1))(linechangedate,yaxis(2)xaxis(2))