📄 twoway_pcspike.hlp
字号:
{smcl}
{* 08apr2005}{...}
{cmd:help twoway pcspike}{right:dialogs: {dialog twoway_overlay:overlaid twoway}{space 0}}
{right:{dialog twoway_simple:single twoway}{space 2}}
{hline}
{title:Title}
{p2colset 5 33 35 2}{...}
{p2col :{hi:[G] graph twoway pcspike} {hline 2}}Paired-coordinate plot with spikes{p_end}
{p2colreset}{...}
{* index twoway pcspike tt}{...}
{* index paired-coordinate plots, pcspike}{...}
{title:Syntax}
{p 8 60 2}
{cmdab:tw:oway}
{cmd:pcspike}
{it:y1var} {it:x1var} {it:y2var} {it:x2var}
{ifin}
[{cmd:,}
{it:options}]
{p2colset 9 32 34 2}{...}
{p2col:{it:options}}description{p_end}
{p2line}
INCLUDE help gr_blspike2
INCLUDE help gr_hvpcopt
INCLUDE help gr_axlnk
INCLUDE help gr_twopt
{p2line}
{pin}
All explicit options are {it:rightmost}, except {cmd:vertical}
and {cmd:horizontal}, which are {it:unique}; see {help repeated options}.
{title:Description}
{pstd}
A paired-coordinate spike plot draws a spike (or line) for each observation in
the dataset. The line starts at the coordinate ({it:y1var},{it:x1var}) and
ends at the coordinate ({it:y2var},{it:x2var}).
{title:Options}
INCLUDE help gr_blspikef2
INCLUDE help gr_hvpcoptf
INCLUDE help gr_axlnkf
INCLUDE help gr_twoptf
{title:Remarks}
{pstd}
Remarks are presented under the headings
{help twoway_pcspike##basic_use:Basic use}
{help twoway_pcspike##advanced_use:Advanced use}
{help twoway_pcspike##advanced_use2:Advanced use 2}
{marker basic_use}{...}
{title:Basic use}
{pstd}
We have longitudinal data from 1968 and 1988 on the earnings and total
experience of US women by occupation.
{cmd:. sysuse nlswide1, clear}
{cmd:. list occ wage68 ttl_exp68 wage88 ttl_exp88}
{txt}
{c TLC}{hline 15}{c -}{hline 10}{c -}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
{c |} {res} occ wage68 ttl_e~68 wage88 ttl_e~88 {txt}{c |}
{c LT}{hline 15}{c -}{hline 10}{c -}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
1. {c |} {res}Professionals 6.121874 .860618 10.94776 14.11177 {txt}{c |}
2. {c |} {res} Managers 5.426208 1.354167 11.53928 13.88886 {txt}{c |}
3. {c |} {res} Sales 4.836701 .9896552 7.290306 12.62823 {txt}{c |}
4. {c |} {res} Clerical 4.088309 .640812 9.612672 11.08019 {txt}{c |}
5. {c |} {res} Craftsmen 4.721373 1.091346 7.839769 12.64364 {txt}{c |}
{c LT}{hline 15}{c -}{hline 10}{c -}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
6. {c |} {res} Operatives 4.364782 .7959284 5.893025 11.99362 {txt}{c |}
7. {c |} {res} Transport 1.987857 .5247414 3.200494 8.710394 {txt}{c |}
8. {c |} {res} Laborers 3.724821 .775966 5.264415 10.56182 {txt}{c |}
9. {c |} {res} Other 5.58524 .8278245 8.628641 12.78389 {txt}{c |}
{c BLC}{hline 15}{c -}{hline 10}{c -}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}
{txt}
{pstd}
We graph a spike showing the movement from 1968 values to 1988 values for each
observation (each occupation):
{cmd:. twoway pcspike wage68 ttl_exp68 wage88 ttl_exp88}
{it:({stata "gr_example nlswide1: twoway pcspike wage68 ttl_exp68 wage88 ttl_exp88":click to run})}
{* graph gtpcspike1}{...}
{marker advanced_use}{...}
{title:Advanced use}
{pstd}
{cmd:twoway} {cmd:pcspike} can be usefully combined
with other {cmd:twoway} plottypes. Here we add markers and labeled markers
along with titles and such to improve the graph:
{cmd}{...}
. 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"))
{txt}{...}
{it:({stata "gr_example2 twopcspike1":click to run})}
{* graph gtpcspike2}{...}
{marker advanced_use2}{...}
{title:Advanced use 2}
{pstd}
Drawing the edges of network diagrams is often easier with
{cmd:twoway pcspike} than with other plottypes.
{cmd:. sysuse network1}
{cmd:. twoway pcspike y_c x_c y_l x_l}
{it:({stata "gr_example network1: twoway pcspike y_c x_c y_l x_l":click to run})}
{* graph gtpcspike3}{...}
{pstd}
As with our first example, this graph can be made prettier by combining
{cmd:twoway pcspike} with other plottypes.
{cmd}{...}
. 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))
{txt}{...}
{it:({stata "gr_example2 twopcspike2":click to run})}
{* graph gtpcspike4}{...}
{title:Also see}
{psee}
Manual: {bf:[G] graph twoway pcspike}
{psee}
Online:
{helpb twoway};
{helpb twoway line};
{helpb twoway rspike};
{helpb twoway pccapsym},
{helpb twoway pcarrow},
{helpb twoway pcbarrow},
{helpb twoway pcscatter},
{helpb twoway pci}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -