📄 twoway_area.hlp
字号:
{smcl}
{* 08apr2005}{...}
{cmd:help twoway area}{right:dialogs: {dialog earea:easy area graph}}
{right:{dialog twoway_overlay:overlaid twoway}{space 0}}
{right:{dialog twoway_simple:single twoway}{space 2}}
{hline}
{title:Title}
{p2colset 5 30 32 2}{...}
{p2col :{hi:[G] graph twoway area} {hline 2}}Twoway line plot with area shading{p_end}
{p2colreset}{...}
{title:Syntax}
{p 8 53 2}
{cmdab:tw:oway}
{cmd:area}
{it:yvar} {it:xvar}
{ifin}
[{cmd:,}
{it:options}]
{p2colset 9 31 33 2}{...}
{it:options}{col 31}description
{p2line}
{cmdab:vert:ical}{...}
{col 31}vertical area plot; the default
{cmdab:hor:izontal}{...}
{col 31}horizontal area plot
{cmd:base(}{it:#}{cmd:)}{...}
{col 31}value to drop to; default is 0
{cmdab:nodropb:ase}{...}
{col 31}programmer's option
{cmd:sort}{...}
{col 31}sort by {it:xvar}; recommended
INCLUDE help gr_areaopt
INCLUDE help gr_axlnk
INCLUDE help gr_twopt
{p2line}
{pin}
Option {cmd:base()} is {it:rightmost}; {cmd:vertical}, {cmd:horizontal},
{cmd:nodropbase}, and {cmd:sort} are {it:unique}; see {help repeated options}.
{title:Description}
{pstd}
{cmd:twoway} {cmd:area} displays ({it:y},{it:x}) connected by
straight lines and shaded underneath.
{title:Options}
{phang}
{cmd:vertical} and {cmd:horizontal}
specify either a vertical or a horizontal area plot.
{cmd:vertical} is the default. If {cmd:horizontal} is specified, the
values recorded in {it:yvar} are treated as {it:x} values, and the values
recorded in {it:xvar} are treated as {it:y} values.
That is, to make horizontal plots, do not switch the order of the
two variables specified.
{pmore}
In the {cmd:vertical} case, shading at each {it:xvar}
value extends up or down from 0 according to the corresponding
{it:yvar} values. If 0 is not in the range of the {it:y} axis,
shading extends up or down to the {it:x} axis.
{pmore}
In the {cmd:horizontal} case, shading at each {it:xvar}
value extends left or right from 0 according to the corresponding
{it:yvar} values. If 0 is not in the range of the {it:x} axis,
shading extends left or right to the {it:y} axis.
{phang}
{cmd:base(}{it:#}{cmd:)}
specifies the value from which the shading should extend.
The default is {cmd:base(0)}, and in the above description of options
{cmd:vertical} and {cmd:horizontal}, this default was assumed.
{phang}
{cmd:nodropbase} is a programmer's option and is an alternative to
{cmd:base()}. It specifies that rather than the enclosed area dropping to
{cmd:base(}{it:#}{cmd:)}{hline 2}or {cmd:base(0)}{hline 2}it drops to the
line formed by ({it:y_1},{it:x_1}) and ({it:y_N}, {it:x_N}), where
({it:y_1},{it:x_1}) are the {it:y} and {it:x} values in the first
observation being plotted and ({it:y_N},{it:x_N}) are the values in the
last observation being plotted.
{phang}
{cmd:sort}
specifies that the data be sorted by {it:xvar} before plotting.
{phang}
{it:area_options}
set the look of the shaded areas. The most important of these options is
{cmd:color(}{it:colorstyle}{cmd:)}, which specifies the color of both
the area and its outline; see {it:{help colorstyle}} for a list of color
choices. See {it:{help area_options}} for information on the other
{it:area_options}.
INCLUDE help gr_axlnkf
INCLUDE help gr_twoptf
{title:Remarks}
{pstd}
Remarks are presented under the headings
{help twoway_area##remarks1:Typical use}
{help twoway_area##remarks2:Advanced use}
{help twoway_area##remarks3:Cautions}
{marker remarks1}{...}
{title:Typical use}
{pstd}
We have quarterly data recording the U.S. GNP in constant 1996 dollars:
{cmd:. sysuse gnp96, clear}
{cmd:. list 1/5}
{txt}
{c TLC}{hline 8}{c -}{hline 8}{c TRC}
{c |} {res} date gnp96 {txt}{c |}
{c LT}{hline 8}{c -}{hline 8}{c RT}
1. {c |} {res}1967q1 3631.6 {txt}{c |}
2. {c |} {res}1967q2 3644.5 {txt}{c |}
3. {c |} {res}1967q3 3672 {txt}{c |}
4. {c |} {res}1967q4 3703.1 {txt}{c |}
5. {c |} {res}1968q1 3757.5 {txt}{c |}
{c BLC}{hline 8}{c -}{hline 8}{c BRC}{txt}
{pstd}
In our opinion, the area under a curve should be shaded only if the
area is meaningful:
{cmd:. sysuse gnp96, clear}
{cmd:. twoway area d.gnp96 date}
{it:({stata "gr_example gnp96: twoway area d.gnp96 date":click to run})}
{* graph gtarea1}{...}
{marker remarks2}{...}
{title:Advanced use}
{pstd}
Here is the same graph, but greatly improved with some advanced options:
{cmd}. twoway area d.gnp96 date, xlabel(36(8)164, angle(90))
ylabel(-100(50)200, angle(0))
ytitle("Billions of 1996 Dollars")
xtitle("")
subtitle("Change in U.S. GNP", position(11))
note("Source: U.S. Department of Commerce,
Bureau of Economic Analysis"){txt}
{it:({stata "gr_example2 twoarea":click to run})}
{* graph twoarea}{...}
{marker remarks3}{...}
{title:Cautions}
{pstd}
Be sure that the data are in the order of {it:xvar}, or specify {cmd:area}'s
{cmd:sort} option. If you do neither, you will get something that looks
like modern art:
{cmd:. sysuse gnp96, clear}
{cmd:. generate d = d.gnp96}
{cmd:. generate u = uniform()}
{cmd:. sort u} (put in random order)
{cmd:. twoway area d date}
{it:({stata "gr_example2 twoarea2":click to run})}
{* graph twoarea2}
{title:Also see}
{psee}
Manual: {bf:[G] graph twoway area}
{psee}
Online:
{helpb scatter};
{helpb twoway dot},
{helpb twoway dropline},
{helpb twoway histogram},
{helpb twoway spike};
{helpb graph bar}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -