#set TITLE = "proc rangebar"
#include top
 
.ig >>
<center>
<img src="../gallery/rangebar0.gif">
</center>
.>>

.SH DESCRIPTION
\fBproc rangebar\fR draws one boxplot (also known as box-and-whisker plot).
This is a compact way to display the range and distribution of data.
A rangebar includes a box.  The median is displayed within the box, and
the extent of the box shows the interquartile range (the 25th and 75th percentiles).
Tails at either end show either the 5th and 95th percentiles, the minima and maxima,
or the extent of 1.5 interquartile ranges.
\fBproc rangebar\fR may also be used to show means and standard deviations.

.SH FEATURES
Can compute the necessary statistics, or accept externally calculated ones.
Can output the computed statistics; two formats available.
Can produce rangebars based on median and quartiles, or
mean and standard deviations.
Rangebars may be vertical or horizontal.
Allows appearance control over all lines, the bar, and the median indicator.
Automatic display of N as well as number of missing observations.
Display and reporting of outliers.

.SH EXAMPLES
See the Gallery Rangebar page
.ig >>
<a href="../gallery/gall.rangebar.html"><img src="../gallery/btn/here.gif"></a>
.>>

.SH VARIABLES THAT ARE SET
\fBNVALUES\fR is set to N.  If nothing was plotted, this will be equal to 0.
.LP
The following variables are set as soon as statistics are computed, whether or
not a plot is actually drawn.
.LP
\fBRANGEBARMEDIAN\fR is set to hold the median value.
This might be useful in drawing a line for comparing medians.
Not set when using \fCmeanmode\fR.
.LP
\fBRANGEBARMEAN\fR is set to hold the mean value.
This might be useful in drawing a line for comparing means.
Set only when using \fCmeanmode\fR.
.LP
\fBRANGEBARIQRMIN\fR and \fBRANGEBARIQRMAX\fR are set to hold the
values of the bottom and top of the box.  Not set when using \fCmeanmode\fR.
.LP
\fBRANGEBARMIN\fR and \fBRANGEBARMAX\fR are set to hold the
values at the ends of the tails.
.LP

.SH UNPLOTTABLE DATA
Invalid values are omitted (however the number of invalids may be shown
using the \fCprintm\fR option).  
Rangebars that lie completely out of the plotting
area are omitted with a warning.
If outliers are being plotted, outliers that are out of range
are omitted with a warning.
Unless \fCtruncate\fR is set to \fCno\fR,
bars and tails are truncated to the bounds of the
plotting area. 


.SH MODES
This proc can calculate the median, quartiles, etc.
(use the \fCdatafield\fR attribute) before drawing the box plot.
Or it can plot from pre-calculated descriptive statistic values,
if the \fCvalues\fR or \fCplotfields\fR attributes are used.
.LP
There is also \fCmeanmode\fR which just calculates mean & 
standard deviation and draws an error bar.
.LP
To turn on display of outliers, set \fCshowoutliers\fR to \fCyes\fR.
.LP
Computed statistics may be written to a file, stderr, etc.
This proc may also be used \fIonly\fR to compute statistics
(and set variables)
without doing any plotting at all\(em see \fCstatsonly\fR.


.SH PREREQUISITES
A plotting area must be set up using \fBproc areadef\fR 
and \fBproc getdata\fR must be executed to 
access or define some data.



.SH MANDATORY ATTRIBUTES
None.  Default behavior is for statistics to be calculated from
data field 1 to produce a vertical rangebar against the Y axis
at X location 1.0  and for an \fCN=\fR label to be placed just
above the X axis.

.SH ATTRIBUTES
.LP
\fBaxis\fR \fCx\fR | \fCy\fR
.IP
Determines which axis to plot against.
\fCx\fR results in horizontal rangebars, while
\fCy\fR results in vertical ones.  Default is \fCy\fR.
Example: \fCaxis: x\fR

.LP
\fBdatafield\fR 
.ig >>
<a href="attributetypes.html#dfield">
.>>
\fI dfield \fR
.ig >>
</a>
.>>
.IP
Specifies the data field on which to compute descriptive statistics.
Example: \fCdatafield: 2\fR

.LP
\fBbarloc\fR 
.ig >>
<a href="attributetypes.html#plotvalue">
.>>
\fI plotvalue \fR
.ig >>
</a>
.>>
.IP
Location where the rangebar is to be rendered.
For vertical boxplots this is a plottable value in X;
for horizontal boxplots this is a plottable value in Y.
Example: \fCbarloc: 3\fR

.LP
\fBbarwidth\fR \fIn\fR
.IP
The width of the box portion of the rangebar in 
.ig >>
<a href="attributetypes.html#positionunits">
.>>
absolute units
.ig >>
</a>
.>>
  .  Default is 0.2 inches.
Example: \fCbarloc: 0.1\fR

.LP
\fBmediansym\fR 
.ig >>
<a href="symboldetails.html">
.>>
\fI symboldetails \fR
.ig >>
</a>
.>>
 | line
.IP
Specifies the symbol that will be displayed to show the median.
May be a symbol specification (to get dots, etc.) or \fCline\fR which
is the default.
Example: \fCmediansym: shape=diamond\fR

.LP
\fBvalues\fR \fI5thpercentile 25th median 75th 95th [N]\fR
.IP
Specify pre-computed descriptive statistics that should just
be plotted.  5 plottable values should be given.  If a 6th value
is given it is taken to be N, and \fCprintn\fR is implied.
Min/max may be substituted for the 5th and 95th percentiles
if desired.
.br
Example: \fCvalues: 0.3 3.0 5.3 6.2 9.4 236\fR

.LP
\fBplotfields\fR \fI5thpercentile 25th median 75th 95th [N]\fR
.br
or with \fCmeanmode\fR: \fBplotfields\fR \fImean stddev [N]\fR  
.IP
Similar to \fCvalues\fR but rather than literal values, a set of 
.ig >>
<a href="attributetypes.html#dfield">
.>>
\fI dfields \fR
.ig >>
</a>
.>>
are given.  The data will be accessed from one row, which may be
specified using \fCplotrecord\fR.  (If \fCplotrecord\fR not specified,
data will be taken from the first row by default.  Proc processdata
action: select may be used to isolate one row of data.)
Example: 
.br
\fCplotfields: 1 2 3 4 5
.br
plotrecord: 1\fR

.LP
\fBplotrecord\fR \fIn\fR
.IP
Used with \fCplotfields\fR; indicates which data row to get the values from.
First row is \fC1\fR.  Example: see \fCplotfields\fR above.
If not specified, first row is assumed.

.LP
\fBtailmode\fR \fC5/95 | minmax | 1.5iqr\fR
.IP
Specifies whether the rangebar tails are to extend to the 5th and 95th percentile,
to the min and max, or using 1.5 x IQR.
Only relevant when statistics are computed internally.
Default is \fC5/95\fR.
.br
Note: 1.5irq mode causes the tails to be rendered using the IQR, which is the
interquartile range (the difference between 75th and 25th percentiles).  
This follows the formal Tukey specification, in that the
lower tail will extend from the bottom of the box downward to the nearest data 
point on or above (25th - (1.5 x IQR)).  Similar for upper tail.

Example: \fCtailmode: minmax\fR

.LP
\fB95tics\fR \fCyes \fR|\fC no\fR
.IP
If \fCtailmode\fR is \fCminmax\fR, allows display of 5th and 95th percentile
by adding tics.
Example: \fC95tics: yes\fR

.LP
\fBtaildetails\fR 
.ig >>
<a href="linedetails.html">
.>>
\fI linedetails \fR
.ig >>
</a>
.>>
.IP
Controls color, width, etc. of tail lines.
.br
Example: \fCtaildetails: color=blue width=1.8\fR

.LP
\fBoutline\fR \fCyes \fR| \fCno\fR
.IP
If \fCyes\fR, box is outlined with a line.

.LP
\fBoutlinedetails\fR 
.ig >>
<a href="linedetails.html">
.>>
\fI linedetails \fR
.ig >>
</a>
.>>
.IP
Controls color, width, etc. of box outline.

.LP
\fBcolor\fR 
.ig >>
<a href="color.html">
.>>
\fI color \fR
.ig >>
</a>
.>>
.IP
Specifies the color of the box area.
Example: \fCcolor: yellow\fR

.LP
\fBtruncate\fR  \fCyes\fR | \fCno\fR
.IP
If \fCyes\fR, bars are truncated to plotting area.
Default is \fCyes\fR.

.LP
\fBticlen\fR \fIn\fR
.IP
Length, in 
.ig >>
<a href="attributetypes.html#positionunits">
.>>
\fI absolute units \fR
.ig >>
</a>
.>>
 , of the tics which appear at the end of the tails.
Default is 70% of the width of the bar.

.LP
\fBmeanmode\fR \fCyes\fR | \fCno\fR
.IP
If yes, mean and standard deviation are computed and drawn as
an error bar, instead of a boxplot of median/quartiles, etc.
Mean is shown as a point (style can be controlled using \fCmediansym\fR).
Number of standard deviations may be controlled using \fCnstddevs\fR.
Cannot be used with \fCvalues\fR; use \fBproc bars\fR instead.
Appearance of the lines may be controlled using \fCtaildetails\fR.

.LP
\fBlogmean\fR  \fCyes\fR | \fCno\fR
.IP
If yes, mean and standard deviation are computed in log space.
Useful with data having log characteristics; when plotted in
log space the standard deviations will appear equidistant from the mean.
If log+1 scaling is in effect for the plot, then this feature 
will operate in log+1 space (allowing 0.0 values).
New in version 1.40.

.LP
\fBskipmed\fR \fCyes\fR | \fCno\fR
.IP
When using \fCmeanmode\fR, this attribute may be specified as \fCyes\fR to speed things
up a bit by avoiding computation of medians and percentiles.
Default is always \fCno\fR.

.LP
\fBnstddevs\fR \fIn\fR
.IP
Used with \fCmeanmode\fR.  Specifies the number of standard deviations
to use in each direction when drawing the error bar.  Default is 1.

.LP
\fBmeansym\fR  \fCyes\fR | 
.ig >>
<a href="symboldetails.html">
.>>
\fI symboldetails \fR
.ig >>
</a>
.>>
.IP
Specifies a symbol to be placed at the mean, when a median-based rangebar
is being rendered.  If \fCyes\fR, a default symbol (a small black dot)
will be placed at the mean  
(its symbol specification is: \fCshape=circle style=filled fillcolor=black radius=0.02\fR)
Other symbols may be rendered by giving
other symboldetails specifications.  If \fCno\fR, a mean symbol will not 
be rendered.  Default is \fCno\fR.
.br
Example: \fCsymboldetails: yes\fR

.LP
\fBselect\fR 
.ig >>
<a href="condex.html">
.>>
\fI conditional-expresion\fR
.ig >>
</a>
.>>
.IP
Only relevant when computing statistics internally.
Allows cases to be selected for inclusion using a selection expression.

.LP
\fBstatsonly\fR \fCyes\fR | \fCno\fR
.IP
If yes, statistics will be computed and internal @variables set, but nothing
will be plotted.
New in version 1.40.


.SH PERTAINING TO OUTPUT OF COMPUTED STATS
.LP
\fBshowstats\fR \fCyes \fR| \fCno\fR | \fConly\fR
.IP
If \fCyes\fR or \fConly\fR, all the computed descriptive statistics 
will be written to the showstatsfile.
If \fConly\fR, the statistics will be printed but no bars will be drawn.

.LP
\fBshowbriefstats\fR \fCyes \fR| \fCno\fR | \fConly\fR
.IP
If yes, and if N > 0, the most important computed descriptive statistics 
will be written to the showstatsfile.  All fields are on one line, TAB-delimited,
for convenient use by other programs.
The fields are in this order: 
.IP
tag, datafield, N, mean, standard deviation, median, min, max, #missing.
.IP
The tag contents may be set using the \fCbriefstatstag\fR attribute; if this attribute is not
set then the first result field will be datafield. 

.LP
\fBbriefstatstag\fR text
.IP
Set the contents of the tag that will be written at the beginning of each 'briefstats' record.
This may be useful in identifying cases and groups in the 'brief stats' output.

.LP
\fBshowstatsfile\fR \fIfilename\fR
.IP
If specified, statistics will be written to this file.
If not specified, statistics will be written to the diagnostic stream,
usually stderr.
File will be opened in \fBappend\fR mode, so the caller may want 
to remove previous contents of the file before invoking ploticus.



.SH PERTAINING TO THE N= and MISSING= LABELS
.LP
\fBprintn\fR \fCyes \fR| \fCno\fR
.IP
If \fCyes\fR, a label showing N (the number of observations) is produced.
Default is \fCyes\fR.
Example: \fCprintn: no\fR

.LP
\fBnlocation\fR 
.ig >>
<a href="attributetypes.html#locvalue">
.>>
\fI locvalue \fR
.ig >>
</a>
.>>
.IP
Where to position the N label.  The label will be aligned with the rangebar.
For vertical rangebars \fClocation\fR indicates where to place the label
in Y; for horizontal, X.
Example: \fCnlocation: -4\fR

.LP
\fBnword\fR 
.ig >>
<a href="attributetypes.html#string">
.>>
\fI string \fR
.ig >>
</a>
.>>
.IP
A template that determines the format of the N label.
Default is \fCN=@@N\fR.
The N value is substituted for the \fC@@N\fR symbol.
Example: \fC(N = @@N)\fR


.LP
\fBprintmissing\fR \fCyes\fR | \fCno\fR
.IP
If \fCyes\fR, a label showing the number of non-plottable (missing) values is produced.
Only relevant if statistics are calculated internally.
Example: \fCprintmissing: yes\fR

.LP
\fBmlocation\fR 
.ig >>
<a href="attributetypes.html#locvalue">
.>>
\fI locvalue \fR
.ig >>
</a>
.>>
.IP
Where to position the missing values label.  
The label will be aligned with the rangebar.
For vertical rangebars \fClocation\fR indicates where to place the label
in Y; for horizontal, X.

.LP
\fBmword\fR 
.ig >>
<a href="attributetypes.html#string">
.>>
\fI string \fR
.ig >>
</a>
.>>
.IP
A template that determines the format of the label showing number of
missing values.
Default is \fCM=@@M\fR.
The N value is substituted for the \fC@@M\fR symbol.
Example: \fC(@@M missing)\fR


.LP
\fBntextdetails\fR 
.ig >>
<a href="textdetails.html">
.>>
\fI textdetails \fR
.ig >>
</a>
.>>
.IP
Set the size, color, font or fine-tune the position of the N labels.
Alternate name for backward compatibility: \fCtextdetails\fR.
.br
Example: \fCntextdetails: size=8 style=I\fR

.LP
\fBmtextdetails\fR 
.ig >>
<a href="textdetails.html">
.>>
\fI textdetails \fR
.ig >>
</a>
.>>
.IP
Set the size, color, font or fine-tune the position of the missing labels.
.br
Example: \fCmtextdetails: size=8 adjust=0,0.05\fR

.LP
\fBmwhenexists\fR \fC yes|no\fR
.IP
If \fCyes\fR, the missing label will be displayed only if the number of
missing observations is greater than 0.  Default is \fCno\fR.



.SH OUTLIER HANDLING OPTIONS
.LP
All of these attributes were introduced in version 1.3.

.LP
\fBshowoutliers\fR \fCyes\fR | \fCno\fR
.IP
If \fCyes\fR, outliers will be displayed and/or reported upon.
An outlier is any point that is beyond the end of either of the rangebar's tails.
The default way of displaying outliers is circles for the near outliers
and asterisks for the far outliers.  The default boundary between near
and far is 3 times the interquartile range.

.LP
\fBoutlierprint\fR \fCyes\fR | \fCno\fR
.IP
If \fCyes\fR, a report on each outlier will be printed to standard error.

.LP
\fBoutliernearsym\fR
.ig >>
<a href="symboldetails.html">
.>>
\fI symboldetails \fR
.ig >>
</a>
.>>
 | \fCnone\fR
.IP
Specifies the symbol for displaying near outliers.
Default is a small circle: \fCshape=circle style=outline radius=0.05\fR.
Use \fCnone\fR if you are displaying outliers as lines or labels
and don't want any geometric symbol.

.LP
\fBoutlierfarsym\fR
.ig >>
<a href="symboldetails.html">
.>>
\fI symboldetails \fR
.ig >>
</a>
.>>
 | \fCnone\fR
.IP
Specifies the symbol for displaying far outliers.
Default is an asterisk: \fCshape=circle style=spokes radius=0.05\fR
Use \fCnone\fR if you are displaying outliers as lines or labels
and don't want any geometric symbol.

.LP
\fBoutliernearfarcutoff\fR  \fIn\fR
.IP
The boundary between near outliers and far outliers will be \fIn\fR times
the interquartile range.  Default is 3.0.

.LP
\fBoutlierlinelen\fR  \fIn\fR
.IP
Display outliers as line segments.
If specified, all outliers (near and far) 
are displayed as short line segments rather than symbols.
\fIn\fR will be the length of these segments, in 
.ig >>
<a href="attributetypes.html#positionunits">
.>>
\fIabsolute space\fR
.ig >>
</a>
.>>
 .  The color and width of these line segments may be controlled using
\fCoutlierlinedetails\fR.
.br
Example: \fCoutlierlinelen: 0.1\fR

.LP
\fBoutlierlabelfield\fR 
.ig >>
<a href="attributetypes.html#dfield">
.>>
\fI dfield \fR
.ig >>
</a>
.>>
.IP
If specified, the contents of this field will appear as a text label for each outlier.
For vertical rangebars the label will appear a bit to the right 
of the point.
For horizontal rangebars the label will appear in rotated text, a bit above
the point.
The size, style, and location may be adjusted if desired using the \fCoutlierlabeldetails\fR
attribute.

.LP
\fBoutlierlabeldetails\fR
.ig >>
<a href="textdetails.html">
.>>
\fI textdetails \fR
.ig >>
</a>
.>>
.IP
Details related to the outlier labels.  

.LP
\fBoutlierlinedetails\fR
.ig >>
<a href="linedetails.html">
.>>
\fI linedetails \fR
.ig >>
</a>
.>>
.IP
When outliers are being rendered as line segments, specifies
color, line width, etc. of these line segments.

#include bottom
