help twoway pcarrow
help twoway pcbarrow dialog: twoway
-------------------------------------------------------------------------------
Title
[G] graph twoway pcarrow -- Paired-coordinate plot with arrows
Syntax
Directional arrows
twoway pcarrow y1var x1var y2var x2var [if] [in] [, options]
Bidirectional arrows
twoway pcbarrow y1var x1var y2var x2var [if] [in] [, options]
options description
---------------------------------------------------------------------
mstyle(markerstyle) overall style of arrowhead
msize(markersizestyle) size of arrowhead
mangle(anglestyle) angle of arrowhead
barbsize(markersizestyle) size of filled portion of arrowhead
mcolor(colorstyle) color of arrowhead, inside and out
mfcolor(colorstyle) arrowhead "fill" color
mlcolor(colorstyle) arrowhead outline color
mlwidth(linewidthstyle) arrowhead outline thickness
mlstyle(linestyle) thickness and color
line_options change look of arrow shaft lines
marker_label_options add marker labels; change look or position
headlabel label head of arrow, not tail
vertical orient plot naturally; the default
horizontal orient plot transposing y and x values
axis_choice_options associate plot with alternative axis
twoway_options titles, legends, axes, added lines and
text, by, regions, name, aspect ratio,
etc.
---------------------------------------------------------------------
Most options are rightmost, except axis_choice_options, headlabel,
vertical, and horizontal, which are unique, and twoway_options, which
are a mix of forms; see repeated options.
Menu
Graphics > Twoway graph (scatter, line, etc.)
Description
twoway pcarrow draws an arrow for each observation in the dataset. The
arrow starts at the coordinate (y1var,x1var) and ends at the coordinate
(y2var,x2var), with an arrowhead drawn at the ending coordinate.
twoway pcbarrow draws an arrowhead at each end; that is, it draws
bidirectional arrows.
Options
mstyle(markerstyle) specifies the overall look of arrowheads, including
their size, their color, etc. The other options allow you to change
each attribute of the arrowhead, but mstyle() is the point from which
they start.
You need not specify mstyle() just because you want to change the
look of the arrowhead. In fact, most people seldom specify the
mstyle() option. You specify mstyle() when another style exists that
is exactly what you desire or when another style would allow you to
specify fewer changes to obtain what you want.
pcarrow plots borrow their options and associated "look" from
standard markers, so all its options begin with m. See [G]
markerstyle for a list of available marker/arrowhead styles.
msize(markersizestyle) specifies the size of arrowheads. See [G]
markersizestyle for a list of size choices.
mangle(anglestyle) specifies the angle that each side of an arrowhead
forms with the arrow's line. For most schemes, the default angle is
28.64.
barbsize(markersizestyle) specifies the portion of the arrowhead that is
to be filled. barbsize(0) specifies that just the lines for the
arrowhead be drawn. When barbsize() is equal to msize(), the
arrowhead is filled to a right angle with the arrow line. The effect
of barbsize() is easier to see than to describe; click here to see a
graph with examples.
mcolor(colorstyle) specifies the color of the arrowhead. This option
sets both the color of the line used to outline the arrowhead and the
color of the inside the arrowhead. Also see options mfcolor() and
mlcolor() below. See [G] colorstyle for a list of color choices.
mfcolor(colorstyle) specifies the color of the inside the arrowhead. See
> [G] colorstyle for a list of color choices.
mlstyle(linestyle), mlwidth(linewidthstyle), and mlcolor(colorstyle)
specify the look of the line used to outline the arrowhead. See
lines, but you cannot change the line pattern of an arrowhead.
line_options specify the look of the lines used to draw the shaft of the
arrow, including pattern, width, and color; see [G] line_options.
marker_label_options specify if and how the arrows are to be labeled. By
default, the labels are placed at the tail of the arrow, the point
defined by y1var and x1var. See [G] marker_label_options for options
that change the look of the labels.
headlabel specifies that labels be drawn at the arrowhead, the
(y2var,x2var) points rather than at the tail of the arrow, the
(y1var,x1var) points. By default, when the mlabel() option is
specified, labels are placed at the tail of the arrows; headlabel
moves the labels from the tail to the head.
vertical and horizontal specify whether the y and x coordinates are to be
swapped before plotting -- vertical (the default) does not swap the
coordinates, whereas horizontal does.
These options are rarely used when plotting only paired-coordinate
data; they can, however, be used to good effect when combining
paired-coordinate plots with range plots, such as twoway rspike or
twoway rbar.
axis_choice_options associate the plot with a particular y or x axis on
the graph; see [G] axis_choice_options.
twoway_options are a set of common options supported by all twoway
graphs. These options allow you to title graphs, name graphs,
control axes and legends, add lines and text, set aspect ratios,
create graphs over by() groups, and change some advanced settings.
See [G] twoway_options.
Remarks
Remarks are presented under the following headings:
Basic use
Advanced use
Basic use
We have longitudinal data from 1968 and 1988 on the earnings and total
experience of U.S. women by occupation. We will input data for two
arrows, both originating at (0,0) and extending at right angles from each
other, and plot them.
. input y1 x1 y2 x2
1. 0 0 0 1
2. 0 0 1 0
3. end
. twoway pcarrow y1 x1 y2 x2
(click to run)
We could add labels to the heads of the arrows while also adding a little
room in the plot region and constraining the plot region to be square:
. drop _all
. input y1 x1 y2 x2 str10 time pos
1. 0 0 0 1 "3 o'clock" 3
2. 0 0 1 0 "12 o'clock" 12
3. end
. twoway pcarrow y1 x1 y2 x2, aspect(1) mlabel(time) headlabel
mlabvposition(pos) plotregion(margin(vlarge))
(click to run)
For examples of arrows in graphing multivariate results, see [MV] biplot.
Advanced use
As with many twoway plottypes, pcarrow and pcbarrow can be usefully
combined with other plottypes. Here a scatter plot is used to label
ranges drawn by pcbarrow (though admittedly the ranges might better be
represented using twoway rcap).
. sysuse nlsw88, clear
. keep if occupation <= 8
. collapse (p05) p05=wage (p95) p95=wage (p50) p50=wage, by(occupation)
. gen mid = (p05 + p95) / 2
. gen dif = (p95 - p05)
. gsort -dif
. gen srt = _n
. twoway pcbarrow srt p05 srt p95 ||
scatter srt mid, msymbol(i) mlabel(occupation)
mlabpos(12) mlabcolor(black)
plotregion(margin(t=5)) yscale(off)
ylabel(, nogrid) legend(off)
ytitle(Hourly wages)
title("90 Percentile Range of US Women's Wages by Occupation")
note("Source: National Longitudinal Survey of Young Women")
(click to run)
Also see
Manual: [G] graph twoway pcarrow
Help: [G] graph twoway; [G] graph twoway pcarrowi, [G] graph twoway
pcspike, [G] graph twoway pccapsym, [G] graph twoway pcscatter,
[G] graph twoway pci