help twoway pcspike dialog: twoway
-------------------------------------------------------------------------------
Title
[G] graph twoway pcspike -- Paired-coordinate plot with spikes
Syntax
twoway pcspike y1var x1var y2var x2var [if] [in] [, options]
options description
---------------------------------------------------------------------
line_options change look of spike lines
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.
---------------------------------------------------------------------
All explicit options are rightmost, except vertical and horizontal,
which are unique; see repeated options.
Menu
Graphics > Twoway graph (scatter, line, etc.)
Description
A paired-coordinate spike plot draws a spike (or line) for each
observation in the dataset. The line starts at the coordinate
(y1var,x1var) and ends at the coordinate (y2var,x2var).
Options
line_options specify the look of the lines used to draw the spikes,
including pattern, width, and color; see [G] line_options.
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
Advanced use 2
Basic use
We have longitudinal data from 1968 and 1988 on the earnings and total
experience of U.S. women by occupation.
. sysuse nlswide1
. list occ wage68 ttl_exp68 wage88 ttl_exp88
+-------------------------------------------------------------+
| occ wage68 ttl_e~68 wage88 ttl_e~88 |
|-------------------------------------------------------------|
1. | Professionals 6.121874 .860618 10.94776 14.11177 |
2. | Managers 5.426208 1.354167 11.53928 13.88886 |
3. | Sales 4.836701 .9896552 7.290306 12.62823 |
4. | Clerical/unskilled 4.088309 .640812 9.612672 11.08019 |
5. | Craftsmen 4.721373 1.091346 7.839769 12.64364 |
|-------------------------------------------------------------|
6. | Operatives 4.364782 .7959284 5.893025 11.99362 |
7. | Transport 1.987857 .5247414 3.200494 8.710394 |
8. | Laborers 3.724821 .775966 5.264415 10.56182 |
9. | Other 5.58524 .8278245 8.628641 12.78389 |
+-------------------------------------------------------------+
We graph a spike showing the movement from 1968 values to 1988 values for
each observation (each occupation):
. twoway pcspike wage68 ttl_exp68 wage88 ttl_exp88
(click to run)
Advanced use
twoway pcspike can be usefully combined with other twoway plottypes.
Here we add markers and labeled markers along with titles and such to
improve the graph:
. twoway pcspike wage68 ttl_exp68 wage88 ttl_exp88 ||
scatter wage68 ttl_exp68, msym(O) ||
scatter wage88 ttl_exp88, msym(O) pstyle(p4)
mlabel(occ) xscale(range(17))
title("Change in US Women's Experience and Earnings")
subtitle("By Occupation -- 1968 to 1988")
ytitle(Earnings) xtitle(Total experience)
note("Source: National Longitudinal Survey of Young Women")
legend(order(2 "1968" 3 "1988"))
(click to run)
Advanced use 2
Drawing the edges of network diagrams is often easier with twoway pcspike
than with other plottypes.
. sysuse network1
. twoway pcspike y_c x_c y_l x_l
(click to run)
As with our first example, this graph can be made prettier by combining
twoway pcspike with other plottypes.
. sysuse network1a
. twoway pcspike y_c x_c y_l x_l, pstyle(p3) ||
pcspike y_c x_c y_r x_r, pstyle(p4) ||
scatter y_l x_l, pstyle(p3) msize(vlarge) msym(O)
mlabel(lab_l) mlabpos(9) ||
scatter y_c x_c, pstyle(p5) msize(vlarge) msym(O) ||
scatter y_r x_r, pstyle(p4) msize(vlarge) msym(O)
mlabel(lab_r) mlabpos(3)
yscale(off) xscale(off) ylabels(, nogrid) legend(off)
plotregion(margin(30 15 3 3))
(click to run)
Also see
Manual: [G] graph twoway pcspike
Help: [G] graph twoway; [G] graph twoway line; [G] graph twoway
rspike; [G] graph twoway pccapsym, [G] graph twoway pcarrow, [G]
graph twoway pcbarrow, [G] graph twoway pcscatter, [G] graph
twoway pci