📄 twoway_rbar.hlp
字号:
{smcl}
{* 08apr2005}{...}
{cmd:help twoway rbar}{right:dialogs: {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 rbar} {hline 2}}Range plot with bars{p_end}
{p2colreset}{...}
{title:Syntax}
{p 8 60 2}
{cmdab:tw:oway}
{cmd:rbar}
{it:y1var} {it:y2var} {it:xvar}
{ifin}
[{cmd:,}
{it:options}]
{p2colset 9 35 37 2}{...}
{it:options}{col 35}description
{p2line}
{cmdab:vert:ical}{...}
{col 35}vertical bars; the default
{cmdab:hor:izontal}{...}
{col 35}horizontal bars
{cmdab:barw:idth:(}{it:#}{cmd:)}{...}
{col 35}width of bar in {it:xvar} units
{cmdab:mw:idth}{...}
{col 35}use {cmd:msize()} rather than {cmd:barwidth()}
{cmdab:msiz:e:(}{it:{help markersizestyle}}{cmd:)}{...}
{col 35}width of bar in {help relativesize:relative size} units
INCLUDE help gr_baropt
INCLUDE help gr_axlnk
INCLUDE help gr_twopt
{p2line}
{pin}
Options {cmd:barwidth()}, {cmd:mwidth}, and {cmd:msize()} are {it:rightmost},
and {cmd:vertical} and {cmd:horizontal} are {it:unique}; see
{help repeated options}.
{title:Description}
{pstd}
A range plot has two {it:y} variables, such as high and low daily stock prices
or upper and lower 95% confidence limits.
{pstd}
{cmd:twoway} {cmd:rbar} plots a range using bars to connect the high and
low values.
{pstd}
Also see {helpb graph bar} for more traditional bar charts.
{title:Options}
{phang}
{cmd:vertical}
and
{cmd:horizontal}
specify whether the high and low {it:y} values are to be presented
vertically (the default) or horizontally.
{pmore}
In the default {cmd:vertical} case, {it:y1var} and {it:y2var} record the
minimum and maximum (or maximum and minimum) {it:y} values to be
graphed against each {it:xvar} value.
{pmore}
If {cmd:horizontal} is specified, the values recorded in {it:y1var} and
{it:y2var} are plotted in the {it:x} direction and {it:xvar} is treated
as the {it:y} value.
{phang}
{cmd:barwidth(}{it:#}{cmd:)}
specifies the width of the bar in {it:xvar} units. The default is
{cmd:width(1)}. When a bar is plotted, it is centered at {it:x}, so half
the width extends below {it:x} and half above.
{phang}
{cmd:mwidth}
and
{cmd:msize(}{it:markersizestyle}{cmd:)}
change how the width of the bars is specified. Usually, the width of the
bars is determined by the {cmd:barwidth()} option documented below. If
{cmd:mwidth} is specified, {cmd:barwidth()} becomes irrelevant and the bar
width switches to being determined by {cmd:msize()}. This all has to do
with the units in which the width of the bar is specified.
{pmore}
By default, bar widths are specified in the units of {it:xvar}, and if
option {cmd:barwidth()} is not specified, the default width is 1 {it:xvar}
unit.
{pmore}
{cmd:mwidth()} specifies that you wish bar widths to be measured in
relative size units; see {it:{help relativesize}}.
When you specify {cmd:mwidth}, the default changes from being 1
{it:xvar} unit to the default width of a marker symbol.
{pmore}
If you also specify {cmd:msize()}, the width of
the bar is modified to be the relative size specified.
INCLUDE help gr_baroptf
INCLUDE help gr_axlnkf
INCLUDE help gr_twoptf
{title:Remarks}
{pstd}
Remarks are presented under the headings
{help twoway rbar##remarks1:Typical use}
{help twoway rbar##remarks2:Advanced use}
{marker remarks1}{...}
{title:Typical use}
{pstd}
We have daily data recording the values for the S&P 500 in 2001:
{cmd:. sysuse sp500, clear}
{cmd:. list date high low close in 1/5}
{txt}
{c TLC}{hline 11}{c -}{hline 9}{c -}{hline 9}{c -}{hline 9}{c TRC}
{c |} {res} date high low close {txt}{c |}
{c LT}{hline 11}{c -}{hline 9}{c -}{hline 9}{c -}{hline 9}{c RT}
1. {c |} {res}02jan2001 1320.28 1276.05 1283.27 {txt}{c |}
2. {c |} {res}03jan2001 1347.76 1274.62 1347.56 {txt}{c |}
3. {c |} {res}04jan2001 1350.24 1329.14 1333.34 {txt}{c |}
4. {c |} {res}05jan2001 1334.77 1294.95 1298.35 {txt}{c |}
5. {c |} {res}08jan2001 1298.35 1276.29 1295.86 {txt}{c |}
{c BLC}{hline 11}{c -}{hline 9}{c -}{hline 9}{c -}{hline 9}{c BRC}{txt}
{pstd}
We will use the first 57 observations from these data:
{cmd:. twoway rbar high low date in 1/57, barwidth(.6)}
{it:({stata "gr_example sp500: twoway rbar high low date in 1/57, barwidth(.6)":click to run})}
{* graph gtrbar1}{...}
{pstd}
We specified {cmd:barwidth(.6)} to reduce the width of the bars. By
default, bars are 1 {it:x} unit wide (meaning 1 day in our data. That
default resulted in the bars touching. {cmd:barwidth(.6)} reduced the width
of the bars to .6 days.
{marker remarks2}{...}
{title:Advanced use}
{pstd}
The useful thing about {cmd:twoway} {cmd:rbar} is that it can be combined
with other {cmd:twoway} plottypes:
{cmd}. twoway rbar high low date, barwidth(.6) color(gs7) ||
line close date || in 1/57{txt}
{it:({stata "gr_example sp500: twoway rbar high low date, barwidth(.6) color(gs7) || line close date || in 1/57":click to run})}
{* graph gtrbar2}{...}
{pstd}
There are two things to note in the example above: our specification of
{cmd:color(gs7)} and that we specified that the range bars be drawn first,
followed by the line. We specified {cmd:color(gs7)} to tone down the bars:
By default, the bars were too bright, making the line plot
of close versus date all but invisible.
Concerning the ordering, we typed
{cmd}. twoway rbar high low date, barwidth(.6) color(gs7) ||
line close date || in 1/57{txt}
{pstd}
so that the bars would be drawn first and then the line drawn over them.
Had we specified
{cmd}. twoway line close date ||
rbar high low date, barwidth(.6) color(gs7) || in 1/57{txt}
{pstd}
the bars would have been placed on top of the line and thus would have occulted
the line.
{title:Also see}
{psee}
Manual: {bf:[G] graph twoway rbar}
{psee}
Online:
{helpb twoway bar};
{helpb twoway rarea},
{helpb twoway rspike},
{helpb twoway rcap},
{helpb twoway rcapsym},
{helpb twoway rline},
{helpb twoway rconnected},
{helpb twoway rscatter}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -