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

📄 graph_combine.hlp

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

	{cmd:. gr combine male.gph female.gph, col(1) iscale(1)}

{pstd}
We must do that, or we must enclose the filenames in quotes:

	{cmd:. gr combine "male" "female"}

	{cmd:. gr combine "male" "female", col(1) iscale(1)}

{pstd}
If we did neither, {cmd:graph} {cmd:combine} would assume that the graphs
were stored in memory and would then have issued the error that the graphs
could not be found.  Had we wanted to do these examples using memory graphs
rather than disk files, we could have substituted {cmd:name()} for saving on
the individual graphs:

	{cmd:. sysuse uslifeexp, clear}

	{cmd:. line le_male   year, name(male)}

	{cmd:. line le_female year, name(female)}

{pstd}
and then we could type the names without quotes on the {cmd:graph}
{cmd:combine} commands:

	{cmd:. gr combine male female}

	{cmd:. gr combine male female, col(1) iscale(1)}


{marker remarks3}{...}
{title:Combining twoway graphs}

{pstd}
In the first example of {hi:Typical use} note that the {it:y} axes of the two
graphs did not align:  One had a minimum of 40 while the other was
approximately 37.  Option {cmd:ycommon} will put all {cmd:twoway} graphs on a
common {it:y} scale.

	{cmd:. sysuse uslifeexp, clear}

	{cmd:. line le_male   year, saving(male)}

	{cmd:. line le_female year, saving(female)}

	{cmd:. gr combine male.gph female.gph, ycommon}
	  {it:({stata "gr_example2 combine3":click to run})}
{* graph combine3}{...}


{marker remarks4}{...}
{title:Advanced use}

	{cmd}. sysuse lifeexp, clear

	. gen loggnp = log10(gnppc)

	. label var loggnp "Log base 10 of GNP per capita"

	. scatter lexp loggnp,
		ysca(alt) xsca(alt)
		xlabel(, grid gmax)      saving(yx)

	. twoway histogram lexp, fraction
		xsca(alt reverse) horiz  saving(hy)

	. twoway histogram loggnp, fraction
		ysca(alt reverse)
		ylabel(,nogrid)
		xlabel(,grid gmax)       saving(hx)

	. graph combine hy.gph yx.gph hx.gph,
		hole(3)
		imargin(0 0 0 0) graphregion(margin(l=22 r=22))
		title("Life expectancy at birth vs. GNP per capita")
		note("Source:  1998 data from The World Bank Group"){txt}
	  {it:({stata "gr_example2 combine4":click to run})}
{* graph combine4}{...}

{pstd}
Note the specification of

		{cmd:imargin(0 0 0 0) graphregion(margin(l=22 r=22))}

{pstd}
on the {cmd:graph} {cmd:combine} statement.
Specifying {cmd:imargin()} pushes the graphs together by eliminating the
margins around them.  Specifying {cmd:graphregion(margin())} makes the
graphs more square{hline 2}to control the aspect ratio.


{* index aspect ratio, controlling}{...}
{* index fysize() tt option}{...}
{* index fxsize() tt option}{...}
{marker remarks5}{...}
{title:Controlling the aspect ratio of subgraphs}

{pstd}
The above graph can be converted to look like this

	  {it:({stata "gr_example2 combine5":click to run})}
{* graph combine5}{...}

{pstd}
by adding {cmd:fysize(25)} to the drawing of the histogram for the {it:x}
axis,

	{cmd}. twoway histogram loggnp, fraction
		ysca(alt reverse)
		ylabel(0(.1).2), nogrid)
		xlabel(,grid gmax)       saving(hx)
		fysize(25){txt}{right:<- {it:new}  }

{pstd}
and adding {cmd:fxsize(25)} to the drawing of the histogram for the {it:y}
axis:

	{cmd}. twoway histogram lexp, fraction
		xsca(alt reverse) horiz
					 saving(hy)
		fxsize(25){txt}{right:<- {it:new}  }

{pstd}
The {cmd:graph} {cmd:combine} command remained unchanged.

{pstd}
The {it:forced_size_options} {cmd:fysize()} and {cmd:fxsize()} are allowed
with any graph; their syntax being

	{it:forced_size_options}{col 35}description
	{hline 62}
	{cmdab:fysiz:e:(}{it:{help relativesize}}{cmd:)}{...}
{col 35}use only percent of height available
	{cmdab:fxsiz:e:(}{it:{help relativesize}}{cmd:)}{...}
{col 35}use only percent of width available
	{hline 62}

{pstd}
There are three ways to control the aspect ratio of a graph:

{phang2}
1.  Specify the {it:region_options} {cmd:ysize(}{it:#}{cmd:)} and
    {cmd:xsize(}{it:#}{cmd:)}; {it:#} is specified in inches.

{phang2}
2.  Specify the {it:region_option}
    {cmd:graphregion(margin(}{it:marginstyle}{cmd:))}.

{phang2}
3.  Specify the {it:forced_size_options}
    {cmd:fysize(}{it:relativesize}{cmd:)}
    and
    {cmd:fxsize(}{it:relativesize}{cmd:)}.

{pstd}
Now let us distinguish between

{phang2}
a.  controlling the aspect ratio of the
overall graph;

{phang2}
b.  controlling the aspect ratio of individual
graphs in a combined graph.

{pstd}
Concerning problem (a), methods (1) and (2) are best.
We used method (2) when we constructed the overall combined
graph above{hline 2}we specified
{cmd:graphregion(margin(l=22 r=22))}.
Methods 1 and 2 are discussed
under {hi:Controlling the aspect ratio} in
{it:{help region_options}}.

{pstd}
Concerning problem (b), method (1) will not work, and methods (2) and (3)
do different things.

{pstd}
Method (1) controls the physical size at which the graph appears, so it
indirectly controls the aspect ratio.  {cmd:graph} {cmd:combine}, however,
discards this physical-size information.

{pstd}
Method (2) is one way of controlling the aspect-ratio of subgraphs.
{cmd:graph} {cmd:combine} honors margins, assuming that you do not specify
{cmd:graph} {cmd:combine}'s {cmd:imargin()} option, which overrides the
original margin information.  In any case, if you want the subgraph long and
narrow, or short and wide, you need only specify the appropriate
{cmd:graphregion(margin())} at the time you draw the subgraph.  When you combine
the resulting graph with other graphs, it will look exactly as you want it.
The long-and-narrow or short-and-wide graph will appear in the array adjacent
to all the other graphs.  The way this works is that each graph is allocated
an equal-sized area in the array, and the oddly shaped graph is drawn into it.

{pstd}
Method (3) is the only way you can obtain unequally sized areas.  In the case
of the combined graph above, you specified {it:graph} {cmd:combine}'s
{cmd:imargin()} option and that alone precluded our use of method (2), but
most importantly, you did not want an array of four equally sized areas:

		{c TLC}{hline 15}{c TT}{hline 15}{c TRC}
		{c |} 1             {c |}             2 {c |}
		{c |}{space 15}{c |}{space 15}{c |}
		{c |}   {it:histogram}   {c |}    {it:scatter}    {c |}
		{c |}{space 15}{c |}{space 15}{c |}
		{c |}{space 15}{c |}{space 15}{c |}
		{c LT}{hline 15}{c +}{hline 15}{c RT}
		{c |} 3             {c |}             4 {c |}
		{c |}{space 15}{c |}{space 15}{c |}
		{c |}               {c |}   {it:histogram}   {c |}
		{c |}{space 15}{c |}{space 15}{c |}
		{c |}{space 15}{c |}{space 15}{c |}
		{c BLC}{hline 15}{c BT}{hline 15}{c BRC}

{pstd}
We wanted

		{c TLC}{hline 3}{c TT}{hline 27}{c TRC}
		{c |} {it:h} {c |}                         2 {c |}
		{c |} {it:i} {c |}                           {c |}
		{c |} {it:s} {c |}                           {c |}
		{c |} {it:t} {c |}                           {c |}
		{c |} {it:o} {c |}         {it:scatter}           {c |}
		{c |} {it:g} {c |}                           {c |}
		{c |} {it:r} {c |}                           {c |}
		{c |} {it:a} {c |}                           {c |}
		{c |} {it:m} {c |}                           {c |}
		{c LT}{hline 3}{c +}{hline 27}{c RT}
		{c |} 3 {c |}        {it:histogram}        4 {c |}
		{c BLC}{hline 3}{c BT}{hline 27}{c BRC}


{pstd}
The {it:forced_size_options} allowed us to achieve that.  You specify the
{it:forced_size_options} {cmd:fysize()} and {cmd:fxsize()} with the commands
that draw the subgraphs, not with {cmd:graph} {cmd:combine}.  Inside the
parentheses, you specify the percent of the graph region to be used.  Although
you could use {cmd:fysize()} and {cmd:fxsize()} to control the aspect ratio in
ordinary cases, there is no reason to do that.  Use {cmd:fysize()} and
{cmd:fxsize()} to control the aspect ratio when you are going to use
{cmd:graph} {cmd:combine} and you want unequally sized areas or when you will
be specifying {cmd:graph} {cmd:combine}'s {cmd:imargin()} option.


{title:Also see}

{psee}
Manual:  {bf:[G] graph combine}

{psee}
Online:  {helpb graph use};
{helpb graph save},
{it:{help saving_option}};
{help gph files}
{p_end}

⌨️ 快捷键说明

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