graph_pie.hlp
来自「是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到」· HLP 代码 · 共 715 行 · 第 1/2 页
HLP
715 行
{pmore}
{it:textbox_options} specify the size, color, etc., of the text; see
{it:{help textbox_options}}.
{phang}
{cmd:ptext(}{it:#_a}
{it:#_r}
{cmd:"}{it:text}{cmd:"}
[{cmd:"}{it:text}{cmd:"} ...]
[{it:#_a} {it:#_r} ...]{cmd:,} {it:ptext_subopts}{cmd:)}
specifies additional text to appear on the pie. The position of the text
is specified by the polar coordinates {it:#_a} and {it:#_r}. {it:#_a}
specifies the angle in degrees, and {it:#_r} specifies the distance from
the origin in relative-size units; see {it:{help relativesize}}.
{phang}
{cmd:intensity(}{it:#}{cmd:)}
and
{cmd:intensity(*}{it:#}{cmd:)}
specify the intensity of the color used to fill the slices.
{cmd:intensity(}{it:#}{cmd:)} specifies the intensity, and
{cmd:intensity(*}{it:#}{cmd:)} specifies the intensity relative to the
default.
{pmore}
Specify {cmd:intensity(*}{it:#}{cmd:)}, {it:#}<1, to attenuate the
interior color and specify {cmd:intensity(*}{it:#}{cmd:)}, {it:#}>1,
to amplify it.
{pmore}
Specify {cmd:intensity(0)} if you do not want the slice filled at all.
{phang}
{cmd:line(}{it:line_options}{cmd:)}
specifies the look of the line used to outline the slices.
See {it:{help line_options}}, but ignore option
{cmd:lpattern()}, which is not allowed in the case of pie charts.
{phang}
{cmd:legend()}
allows you to control the legend.
See {it:{help legend_option}}.
{phang}
{it:std_options}
allow you to add titles, save the graph on disk, and more; see
{it:{help std_options}}.
{phang}
{cmd:by(}{it:varlist}{cmd:,} ...{cmd:)}
draws separate pies within a single graph; see
{it:{help by_option}} and see
{help graph pie##remarks7:Use with by()} under {hi:Remarks} below.
{title:Remarks}
{pstd}
Remarks are presented under the headings
{help graph pie##remarks1:Typical use}
{help graph pie##remarks2:Data are summed}
{help graph pie##remarks3:Data may be long rather than wide}
{help graph pie##remarks4:How slices are ordered}
{help graph pie##remarks5:Ordering slices by size}
{help graph pie##remarks6:Reordering the slices}
{help graph pie##remarks7:Use with by()}
{help graph pie##remarks8:History}
{marker remarks1}{...}
{title:Typical use}
{pstd}
We have been told that the expenditures for XYZ Corp. are
$12 million in sales, $14 million in marketing, $2 million in research, and $8
million in development:
{cmd:. clear}
{cmd:. input sales marketing research development}
{txt} sales marketing research develop~t
1{cmd}. 12 14 2 8
{txt} 2{cmd}. end{txt}
{cmd}. label var sales "Sales"{txt}
{cmd}. label var market "Marketing"{txt}
{cmd}. label var research "Research"{txt}
{cmd}. label var develop "Development"{txt}
{cmd:. graph pie sales marketing research development,}
{cmd:plabel(_all name, size(*1.5) color(white))}{col 66}{it:(Note 1)}
{cmd:legend(off)}{col 66}{it:(Note 2)}
{cmd:plotregion(lstyle(none))}{col 66}{it:(Note 3)}
{cmd:title("Expenditures, XYZ Corp.")}
{cmd:subtitle("2002")}
{cmd:note("Source: 2002 Financial Report (fictional data)")}
{it:({stata "gr_example2 pie1":click to run})}
{* graph grpie1}{...}
{pstd}
Notes:
{phang2}
1. We specified {cmd:plabel(all} {cmd:name)} to put the division names on the
slices. We specified {cmd:plabel()}'s textbox-option {cmd:size(*1.5)}
to make the text 50% larger than usual.
We specified {cmd:plabel()}'s textbox-option {cmd:color(white)} to
make the text white.
See {it:{help textbox_options}}.
{phang2}
2. We specified the legend-option {cmd:legend(off)} to keep the division names
from being repeated in a key at the bottom of the graph;
see {it:{help legend_option}}.
{phang2}
3. We specified the region-option {cmd:plotregion(lstyle(none))} to
prevent a border from being drawn around the plot area;
see {it:{help region_options}}.
{marker remarks2}{...}
{title:Data are summed}
{pstd}
Rather than having the above summary data, we have
{cmd:. list}
{c TLC}{hline 5}{c -}{hline 7}{c -}{hline 11}{c -}{hline 10}{c -}{hline 13}{c TRC}
{c |} {res}qtr sales marketing research development {txt}{c |}
{c LT}{hline 5}{c -}{hline 7}{c -}{hline 11}{c -}{hline 10}{c -}{hline 13}{c RT}
1. {c |} {res} 1 3 4.5 .3 1 {txt}{c |}
2. {c |} {res} 2 4 3 .5 2 {txt}{c |}
3. {c |} {res} 3 3 4 .6 2 {txt}{c |}
4. {c |} {res} 4 2 2.5 .6 3 {txt}{c |}
{c BLC}{hline 5}{c -}{hline 7}{c -}{hline 11}{c -}{hline 10}{c -}{hline 13}{c BRC}{txt}
{pstd}
Note that the sums of these data are the same as the totals in the previous
section. The same {cmd:graph} {cmd:pie} command:
{phang2}
{cmd:. graph pie sales marketing research development,} ...
{pstd}
will result in the same chart.
{marker remarks3}{...}
{title:Data may be long rather than wide}
{pstd}
Rather than having the quarterly data in wide form, we have it in the
long form:
{cmd}. list, sepby(qtr)
{txt}
{c TLC}{hline 5}{c -}{hline 13}{c -}{hline 6}{c TRC}
{c |} {res}qtr division cost {txt}{c |}
{c LT}{hline 5}{c -}{hline 13}{c -}{hline 6}{c RT}
1. {c |} {res} 1 Development 1 {txt}{c |}
2. {c |} {res} 1 Marketing 4.5 {txt}{c |}
3. {c |} {res} 1 Research .3 {txt}{c |}
4. {c |} {res} 1 Sales 3 {txt}{c |}
{c LT}{hline 5}{c -}{hline 13}{c -}{hline 6}{c RT}
5. {c |} {res} 2 Development 2 {txt}{c |}
6. {c |} {res} 2 Marketing 3 {txt}{c |}
7. {c |} {res} 2 Research .5 {txt}{c |}
8. {c |} {res} 2 Sales 4 {txt}{c |}
{c LT}{hline 5}{c -}{hline 13}{c -}{hline 6}{c RT}
9. {c |} {res} 3 Development 2 {txt}{c |}
10. {c |} {res} 3 Marketing 4 {txt}{c |}
11. {c |} {res} 3 Research .6 {txt}{c |}
12. {c |} {res} 3 Sales 3 {txt}{c |}
{c LT}{hline 5}{c -}{hline 13}{c -}{hline 6}{c RT}
13. {c |} {res} 4 Development 3 {txt}{c |}
14. {c |} {res} 4 Marketing 2.5 {txt}{c |}
15. {c |} {res} 4 Research .6 {txt}{c |}
16. {c |} {res} 4 Sales 2 {txt}{c |}
{c BLC}{hline 5}{c -}{hline 13}{c -}{hline 6}{c BRC}{txt}
{pstd}
In this case, rather than typing
{phang2}
{cmd:. graph pie sales marketing research development,} ...
{pstd}
we type
{cmd:. graph pie cost, over(division)} ...
{pstd}
For example,
{cmd:. graph pie cost, over(division),}
{cmd:plabel(_all name, size(*1.5) color(white))}
{cmd:legend(off)}
{cmd:plotregion(lstyle(none))}
{cmd:title("Expenditures, XYZ Corp.")}
{cmd:subtitle("2002")}
{cmd:note("Source: 2002 Financial Report (fictional data)")}
{it:({stata "gr_example2 pie2":click to run})}
{* graph grpie2}{...}
{pstd}
This is the same pie chart as the one drawn previously, except for the order in
which the divisions are presented.
{marker remarks4}{...}
{title:How slices are ordered}
{pstd}
When we type
{phang2}
{cmd:. graph pie sales marketing research development,} ...
{pstd}
the slices are presented in the order we specify. When we type
{cmd:. graph pie cost, over(division)} ...
{pstd}
the slices are presented in the order implied by variable division.
If division is numeric, slices are presented in ascending order
of division. If division is string, slices are presented in
alphabetical order (except that all capital letters occur before lowercase
letters).
{marker remarks5}{...}
{title:Ordering slices by size}
{pstd}
Regardless of whether we type
{phang2}
{cmd:. graph pie sales marketing research development,} ...
{pstd}
or
{cmd:. graph pie cost, over(division)} ...
{pstd}
if we add the {cmd:sort} option, slices will be presented in the
order of the size, smallest first:
{phang2}
{cmd:. graph pie sales marketing research development, sort} ...
{cmd:. graph pie cost, over(division) sort} ...
{pstd}
If we also specify the {cmd:descending} option, the largest slice will
be presented first:
{phang2}
{cmd:. graph pie sales marketing research development, sort descending} ...
{phang2}
{cmd:. graph pie cost, over(division) sort descending} ...
{marker remarks6}{...}
{title:Reordering the slices}
{pstd}
If we wish to force a particular order, then if we type
{phang2}
{cmd:. graph pie sales marketing research development,} ...
{pstd}
specify the variables in the desired order. If we type
{cmd:. graph pie cost, over(division)} ...
{pstd}
then create a numeric variable that has a one-to-one correspondence with
the order in which we wish the divisions to appear. For instance, we might
type
{cmd:. gen order = 1 if division=="Sales"}
{cmd:. replace order = 2 if division=="Marketing"}
{cmd:. replace order = 3 if division=="Research"}
{cmd:. replace order = 4 if division=="Development"}
{pstd}
then type
{phang2}
{cmd:. graph pie cost, over(division) sort(order)} ...
{marker remarks7}{...}
{title:Use with by()}
{pstd}
We have two years of data on XYZ Corp.:
{cmd}. list
{txt}
{c TLC}{hline 6}{c -}{hline 7}{c -}{hline 11}{c -}{hline 10}{c -}{hline 13}{c TRC}
{c |} {res}year sales marketing research development {txt}{c |}
{c LT}{hline 6}{c -}{hline 7}{c -}{hline 11}{c -}{hline 10}{c -}{hline 13}{c RT}
1. {c |} {res}2002 12 14 2 8 {txt}{c |}
2. {c |} {res}2003 15 17.5 8.5 10 {txt}{c |}
{c BLC}{hline 6}{c -}{hline 7}{c -}{hline 11}{c -}{hline 10}{c -}{hline 13}{c BRC}{txt}
{cmd:. graph pie sales marketing research development,}
{cmd:plabel(_all name, size(*1.5) color(white))}
{cmd:by(year,}
{cmd:legend(off)}
{cmd:title("Expenditures, XYZ Corp.")}
{cmd:note("Source: 2002 Financial Report (fictional data)")}
{cmd:)}
{it:({stata "gr_example2 pie3":click to run})}
{* graph grpie3}{...}
{* index histories}{...}
{* index Playfair, William}{...}
{* index Beniger and Robyn 1978}{...}
{* index Funkhouser 1937}{...}
{* index Tufte 1983}{...}
{marker remarks8}{...}
{title:History}
{pstd}
The first pie chart is credited to William Playfair (1801).
See Beniger and Robyn (1978),
Funkhouser (1937, 283-285),
or Tufte (1983, 44-45)
for further historical details.
{title:Also see}
{psee}
Manual: {bf:[G] graph pie}
{psee}
Online:
{helpb graph},
{helpb graph bar}
{p_end}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?