⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 by_option.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
📖 第 1 页 / 共 2 页
字号:

{marker remarks2}{...}
{title:Placement of graphs}

{pstd}
By default, {cmd:by()} places the graphs in a rectangular {it:RxC} array and
leaves empty the positions at the end:

	   Number of      array        positions
	    graphs      dimension      left empty
	   {hline 65}
	       1           1{it:x}1
	       2           1{it:x}2
	       3           2{it:x}2         {cmd:4}=(2,2)
	       4           2{it:x}2
	       5           2{it:x}3         {cmd:6}=(3,3)
	       6           2{it:x}3
	       7           3{it:x}3         {cmd:8}=(3,2)   {cmd:9}=(3,3)
	       8           3{it:x}3         {cmd:9}=(3,3)
	       9           3{it:x}3
	      10           3{it:x}4        {cmd:11}=(3,3)  {cmd:12}=(3,4)
	      11           3{it:x}4        {cmd:12}=(3,4)
	      12           3{it:x}4
	      13           4{it:x}4        {cmd:14}=(4,2)  {cmd:15}=(4,3)  {cmd:16}=(4,4)
	      14           4{it:x}4        {cmd:15}=(4,3)  {cmd:16}=(4,4)
	      15           4{it:x}4        {cmd:16}=(4,4)
	      16           4{it:x}4
	      17           4{it:x}5        {cmd:18}=(4,3)  {cmd:19}=(4,4)  {cmd:20}=(4,5)
	      18           4{it:x}5        {cmd:19}=(4,4)  {cmd:20}=(4,5)
	      19           4{it:x}5        {cmd:20}=(4,5)
	      20           4{it:x}5
	      21           5{it:x}5        {cmd:22}=(5,2)  {cmd:23}=(5,3)  {cmd:24}=(5,4)  {cmd:25}=(5,5)
	      22           5{it:x}5        {cmd:23}=(5,3)  {cmd:24}=(5,4)  {cmd:25}=(5,5)
	      23           5{it:x}5        {cmd:24}=(5,4)  {cmd:25}=(5,5)
	      24           5{it:x}5        {cmd:25}=(5,5)
	      25           5{it:x}5
	     {it:etc.}
	   {hline 65}

{pstd}
Options {cmd:rows()}, {cmd:cols()}, and {cmd:holes()} allow you to control
this behavior.

{pstd}
You may specify either {cmd:rows()} or {cmd:cols()}, but not both.  In the
previous section, we drew

	{cmd:. scatter mpg weight, by(foreign, total)}

{pstd}
and had 3 graphs displayed in a 2{it:x}2 array with a hole at 4.  We could
draw the graph in a 1{it:x}3 array by specifying either {cmd:rows(1)} or
{cmd:cols(3)},

	{cmd:. scatter mpg weight, by(foreign, total rows(1))}
	  {it:({stata "gr_example auto: scatter mpg weight, by(foreign, total rows(1))":click to run})}
{* graph mpgweightbyt1r}{...}

{pstd}
or we could stay with the 2{it:x}2 array and move the hole to 3,

	{cmd:. scatter mpg weight, by(foreign, total holes(3))}
	  {it:({stata "gr_example auto: scatter mpg weight, by(foreign, total holes(3))":click to run})}
{* graph mpgweightbyt3h}{...}


{marker remarks3}{...}
{title:Treatment of titles}

{pstd}
Were you to type,

	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, title("My title") by(catvar)}

{pstd}
"My title" will be repeated above each individual graph.  {cmd:by()} repeats
the entire {cmd:graph} command and then arrays the results.

{pstd}
To specify titles for the entire graph, specify the
{it:title_options}{hline 2}see
{it:{help title_options}}{hline 2}inside the {cmd:by()} option:

	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, by(catvar, title("My title"))}


{marker remarks4}{...}
{title:by() uses the subtitle() with graph}

{pstd}
{cmd:by()} labels each of the individual graphs using the {cmd:subtitle()}
{it:title_option}.  For instance, in

	{cmd:. scatter mpg weight, by(foreign, total)}

{pstd}
{cmd:by()} labeled the graphs "Domestic", "Foreign", and "Total".  The
subtitle "Total" is what {cmd:by()} uses when the {cmd:total} option is
specified.  The other two subtitles {cmd:by()} obtained from the by-variable
{cmd:foreign}.

{pstd}
{cmd:by()} may be used with numeric or string variables.  In this case,
{cmd:foreign} is numeric but happens to have a value label associated with it.
{cmd:by()} obtained the subtitles "Domestic" and "Foreign" from the value
label.  If {cmd:foreign} had no value label, the first two graphs would have
been subtitled "0" and "1", the numeric values of variable {cmd:foreign}.  If
{cmd:foreign} had been a string variable, the subtitles would have been the
string contents of {cmd:foreign}.

{pstd}
If you wish to suppress the subtitle, type

	{cmd:. scatter mpg weight, subtitle("") by(foreign, total)}

{pstd}
If you wish to add "{it:Extra info}" to the subtitle, type

	{cmd:. scatter mpg weight, subtitle("}{it:Extra info}{cmd:", suffix) by(foreign, total)}

{pstd}
Be aware, however, that "{it:Extra info}" will appear above each of the
individual graphs.


{marker remarks5}{...}
{title:Placement of the subtitle()}

{pstd}
You can use {cmd:subtitle()}'s suboptions to control the placement of the
identifying label.  For instance,

	{cmd:. scatter mpg weight,}
		{cmd:subtitle(, ring(0) pos(1) nobexpand) by(foreign, total)}
	  {it:({stata "gr_example auto: scatter mpg weight, subtitle(, ring(0) pos(1) nobexpand) by(foreign, total)":click to run})}
{* graph byopt6}{...}

{pstd}
The result will be to move the identifying label inside the individual graphs,
displaying it in the northeast corner of each.  Type

	{cmd:. scatter mpg weight,}
		{cmd:subtitle(, ring(0) pos(11) nobexpand) by(foreign, total)}

{pstd}
and the identifying label will be moved to the northwest corner.

{pstd}
{cmd:ring(0)} moves the subtitle inside the graph's plot region and
{cmd:position()} defines the location, indicated as clock positions.
{cmd:nobexpand} is rather strange, but just remember to specify it.  By
default, {cmd:by()} sets subtitles to expand to the size of the box that
contains them, which is unusual but makes the default-style subtitles look
good with shading.

{pstd}
See {it:{help title_options}}.


{marker remarks6}{...}
{title:by() uses the overall note()}

{pstd}
By default, {cmd:by()} adds an overall note saying "Graphs by ...".
When you type

	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, by(catvar)}

{pstd}
results are the same as if you typed

	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, by(catvar, note("Graphs by ..."))}

{pstd}
If you want to suppress the note, type

	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, by(catvar, note(""))}

{pstd}
If you want to change the overall note to read "My note", type

	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, by(catvar, note("My note"))}

{pstd}
If you want to add your note after the default note, type

	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, by(catvar, note("My note", suffix))}


{* index legends, use with by() tt}{...}
{* index by() tt, use of legends with}{...}
{marker use_of_legends}{...}
{marker remarks7}{...}
{title:Use of legends with by()}

{pstd}
If you wish to modify or suppress the default legend, you must do that
differently when {cmd:by()} is specified.  For instance,
{cmd:legend(off)}{hline 2}see {it:{help legend_option}}{hline 2}will suppress
the legend, yet typing

	{cmd:. line y1 y2 x, by(group) legend(off)}

{pstd}
will not have the intended effect.  The {cmd:legend(off)} will seemingly be
ignored.  You must instead type

	{cmd:. line y1 y2 x, by(group, legend(off))}

{pstd}
Note that we moved {cmd:legend(off)} inside the {cmd:by()}.

{pstd}
Remember that {cmd:by()} repeats the {cmd:graph} command.  If you think
carefully, you will realize that the legend never was displayed at the
bottom of the individual plots.  It is instructive to type

	{cmd:. line y1 y2 x, legend(on) by(group)}

{pstd}
This graph will have lots of legends:  one underneath each of
the plots in addition to the overall legend at the bottom of the graph!
{cmd:by()} works exactly as advertised:  it repeats the entire graph command
for each value of {cmd:group}.

{pstd}
In any case, it is the overall {cmd:legend()} that we want to suppress, and
that is why we must specify {cmd:legend(off)} inside the {cmd:by()} option;
this is the same issue as the one discussed under {hi:Treatment of titles}
above.

{pstd}
The issue becomes a little more complicated when, rather than suppressing
the legend, we wish to modify the legend's contents or position.  In that case,
the {cmd:legend()} option to modify the contents is specified outside the
{cmd:by()} and the {cmd:legend()} option to modify the location is
specified inside.  See
{hi:{help legend_option##use_of_legends_with_by:Use of legends with by}} in 
{it:legend_option}.


{marker remarks8}{...}
{title:By-styles}

{pstd}
Option {cmd:style(}{it:bystyle}{cmd:)} specifies the overall look of
by-graphs; see {it:{help bystyle}} for a list of {it:bystyle} choices.
One {it:bystyle} worth noting is {cmd:compact}.  Specifying
{cmd:style(compact)} causes the graph to be displayed in a more compact
format.  Compare

	{cmd:. sysuse lifeexp, clear}

	{cmd:. scatter lexp gnppc, by(region, total)}
	  {it:({stata "gr_example lifeexp: scatter lexp gnppc, by(region, total)":click to run})}
{* graph byopt7}{...}

{pstd}
with

	{cmd:. scatter lexp gnppc, by(region, total style(compact))}
	  {it:({stata "gr_example lifeexp: scatter lexp gnppc, by(region, total style(compact))":click to run})}
{* graph byopt8}{...}

{pstd}
{cmd:style(compact)} pushes the graphs together horizontally and vertically,
leaving more room for the individual graphs.
The disadvantage is that, pushed together, the values on the axes labels
sometimes run into each other, as occurred above with the 40,000 of the
S.A. graph running into the 0 of the Total graph.  That problem could be
solved by dividing gnppc by 1,000.

{pstd}
Rather than typing out {cmd:style(compact)}, you may specify
{cmd:compact}, and you may further abbreviate that as {cmd:com}.


{marker remarks9}{...}
{title:Labeling the edges}

{pstd}
Consider the graph

	{cmd:. scatter mpg weight, by(foreign, total)}
	  {it:({stata "gr_example auto: scatter mpg weight, by(foreign, total)":click to run})}
{* graph mpgweightbyt}{...}

{pstd}
and note that the {it:x} axis is labeled in the graph in the (1,2) position.
When the last graph of a column does not appear in the last row, its
{it:x} axis is referred to as an edge.  In {cmd:style(default)}, the
default is to label the edges, but you could type

	{cmd:. scatter mpg weight, by(foreign, total noedgelabel)}
	  {it:({stata "gr_example auto: scatter mpg weight, by(foreign, total noedgelabel)":click to run})}
{* graph byopt9}{...}

{pstd}
to suppress that.  This results in the rows of graphs being closer to each
other.

{pstd}
Were you to type

{phang2}
	{cmd:. scatter mpg weight, by(foreign, total style(compact))}

{pstd}
you would discover that the {it:x} axis of the (1,2) graph is not labeled.
Using {cmd:style(compact)}, the default is {cmd:noedgelabel}, but you
could specify {cmd:edgelabel} to override that.


{marker remarks10}{...}
{title:Specifying separate scales for the separate plots}

{pstd}
If you type

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, by(}{it:catvar}{cmd:, yrescale)}

{pstd}
each graph will be given a separately scaled {it:y} axis; if you type

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, by(}{it:catvar}{cmd:, xrescale)}

{pstd}
each graph will be given a separately scaled {it:x} axis; and if you type

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, by(}{it:catvar}{cmd:, yrescale xrescale)}

{pstd}
both scales will be separately set.


{* index histories}{...}
{* index casement displays}{...}
{* index Chambers, et al.}{...}
{marker remarks11}{...}
{title:History}

{pstd}
The twoway scatterplots produced by the {cmd:by()} option are similar to what
are known as {it:casement} {it:displays}
(see, for instance, Chambers et al.  1983, 141-145).  A traditional casement
display, however, aligns all the graphs either vertically or horizontally.


{title:Also see}

{psee}
Manual:  {bf:[G] {it:by_option}}

{psee}
Online:  {it:{help region_options}},
{it:{help title_options}}
{p_end}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -