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

📄 scatter.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
📖 第 1 页 / 共 3 页
字号:
	{help scatter##remarks18:Saving graphs}
	{help scatter##remarks19:Appendix:  Styles and composite styles}


{marker remarks1}{...}
{title:Typical use}

{pstd}
The scatter plottype by default individually marks the location of each
point:

	{cmd:. sysuse uslifeexp2, clear}

	{cmd:. scatter le year}
	  {it:({stata "gr_example uslifeexp2: scatter le year":click to run})}
{* graph scatter1}{...}

{pstd}
With the specification of options, you can produce the same effect
as {cmd:twoway} {cmd:connected},

	{cmd:. scatter le year, connect(l)}
	  {it:({stata "gr_example uslifeexp2: scatter le year, c(l)":click to run})}
{* graph scatter2}{...}

{pstd}
or {cmd:twoway} {cmd:line}:

	{cmd:. scatter le year, connect(l) msymbol(i)}
	  {it:({stata "gr_example uslifeexp2: scatter le year, c(l) m(i)":click to run})}
{* graph scatter3}{...}

{pstd}
In fact, all the other twoway plottypes eventually work their way back to
executing {cmd:scatter}.  {cmd:scatter} literally is the mother of all twoway
graphs in Stata.


{marker remarks2}{...}
{title:Scatter syntax}

{pstd}
See {helpb twoway} for an overview of {cmd:graph} {cmd:twoway} syntax.  In
the particular case of {cmd:graph} {cmd:twoway} {cmd:scatter}, the only thing
to know is that if more than two variables are specified, all but the last are
given the interpretation of being {it:y} variables.  For example,

	{cmd:. scatter} {it:y1var} {it:y2var} {it:xvar}

{pstd}
would plot {it:y1var} versus {it:xvar} and overlay that with a plot of
{it:y2var} versus {it:xvar}, so it is the same as typing

{phang2}
	{cmd:. scatter} {it:y1var} {it:xvar} {cmd:|| scatter} {it:y2var xvar}

{pstd}
If, using the multiple-variable syntax, you specify {cmd:scatter}-level
options (i.e., all options except {it:twoway_options} as defined in the
syntax diagram), you specify arguments for {it:y1var}, {it:y2var}, ...,
separated by spaces.  That is, you might type

{phang2}
	{cmd:. scatter} {it:y1var} {it:y2var} {it:xvar}{cmd:, ms(O i) c(. l)}

{pstd}
{cmd:ms()} and {cmd:c()} are abbreviations for the {cmd:msymbol()} and
{cmd:connect()} options.  In any case, the results from the above are
the same as if you typed

{phang2}
	{cmd:. scatter} {it:y1var} {it:xvar}{cmd:, ms(O) c(.)}
		{cmd:|| scatter} {it:y2var} {it:xvar}{cmd:, ms(i) c(l)}

{pstd}
There need not be a one-to-one correspondence between options and {it:y}
variables when you use the multiple-variable syntax.  If you typed

{phang2}
	{cmd:. scatter} {it:y1var} {it:y2var} {it:xvar}{cmd:, ms(O) c(l)}

{pstd}
then options {cmd:ms()} and {cmd:c()} will have default values for the
second scatter, and if you typed

{phang2}
	{cmd:. scatter} {it:y1var} {it:y2var} {it:xvar}{cmd:, ms(O S i) c(l l l)}

{pstd}
the extra options for the nonexistent third variable would be ignored.

{pstd}
If you wish to specify the default for one of the {it:y} variables, you
may specify period ({cmd:.}):

{phang2}
	{cmd:. scatter} {it:y1var} {it:y2var} {it:xvar}{cmd:, ms(. O) c(. l)}

{pstd}
There are other shorthands available to make specifying multiple arguments
easier; see {help stylelists}.

{pstd}
Since multiple variables are interpreted as multiple {it:y} variables,
to produce graphs containing multiple {it:x} variables, you must
chain together separate {cmd:scatter} commands:

{phang2}
	{cmd:. scatter} {it:yvar} {it:x1var}{cmd:,} ... {cmd:||}
		{cmd:. scatter} {it:yvar} {it:x2var}{cmd:,} ...


{marker remarks3}{...}
{title:The overall look for the graph}

{pstd}
The overall look of the graph is mightily affected by the scheme, and note
that there is a {cmd:scheme()} option that will allow you to specify which
scheme to use.
We showed earlier the results of {cmd:scatter}
{cmd:le} {cmd:year}.  Here is the same graph repeated using the
{cmd:economist} scheme:

	{cmd}. sysuse uslifeexp2, clear

	. scatter le year,
		title("Scatter plot")
		subtitle("Life expectancy at birth, U.S.")
		note("1")
		caption("Source:  National Vital Statistics Report,
			 Vol. 50 No. 6")
		scheme(economist){txt}
	  {it:({stata "gr_example2 grscae":click to run})}
{* graph scatter4}{...}

{pstd}
See {help schemes}.


{marker remarks4}{...}
{title:The size and aspect ratio of the graph}

{pstd}
The size and aspect ratio of the graph are controlled by the
{it:region_options} {cmd:ysize(}{it:#}{cmd:)} and {cmd:xsize(}{it:#}{cmd:)},
which specify the height and width in inches of the graph.
For instance,

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, xsize(4) ysize(4)}

{pstd}
would produce a 4{it:x}4 inch square graph.
See {it:{help region_options}}.


{marker remarks5}{...}
{title:Titles}

{pstd}
By default, no titles appear on the graph, but the {it:title_options}
{cmd:title()}, {cmd:subtitle()}, {cmd:note()}, {cmd:caption()}, and
{cmd:legend()} allow you to specify the titles that you wish to appear, as
well as to control their position and size.  For instance,

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

{pstd}
would draw the graph and include the title "My title" (without the quotes) at
the top.  Multiple-line titles are allowed.  Typing

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, title("My title" "Second line")}

{pstd}
would create a two-line title.  The above, however, would probably look better
as a title followed by a subtitle:

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, title("My title") subtitle("Second line")}

{pstd}
In any case,
see {it:{help title_options}}.


{marker remarks6}{...}
{title:Axis titles}

{pstd}
Titles do, by default, appear on the {it:y} and {it:x} axes.  The axes are
titled with the variable names being plotted or, if the variables have
variable labels, with their variable labels.  The {it:axis_title_options}
{cmd:ytitle()} and {cmd:xtitle()} allow you to override that.  If you specify

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, ytitle("")}

{pstd}
the title on the {it:y} axis would disappear.  If you specify

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, ytitle("Rate of change")}

{pstd}
the {it:y}-axis title would become "Rate of change".
As with all titles, multiple-line titles are allowed:

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, ytitle("Time to event" "Rate of change")}

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


{marker remarks7}{...}
{title:Axis labels and ticking}

{pstd}
By default, approximately five major ticks and labels are placed on each axis.
The {it:axis_label_options} {cmd:ylabel()} and {cmd:xlabel()} allow you to
control that.  Typing

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, ylabel(#10)}

{pstd}
would put approximately ten labels and ticks on the {it:y} axis.  Typing

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, ylabel(0(1)9)}

{pstd}
would put exactly ten labels at the values 0, 1, ..., 9.

{pstd}
{cmd:ylabel()} and {cmd:xlabel()} have other features, and options are also
provided for minor labels and minor ticks; see 
{it:{help axis_label_options}}.


{marker remarks8}{...}
{title:Grid lines}

{pstd}
Assuming that you use a member of the {cmd:s2} family
of schemes{hline 2}see {help scheme s2}{hline 2}grid lines are included
in {it:y} but not {it:x}, by default.
You can specify option {cmd:xlabel(,grid)} to add {it:x} grid lines,
and you can specify {cmd:ylabel(,nogrid)} to suppress {it:y}
grid lines.

{pstd}
Grid lines are considered
an extension of ticks and are specified as suboptions inside the
{it:axis_label_options} {cmd:ylabel()} and {cmd:xlabel()}.  For instance,

	{cmd:. sysuse auto, clear}

	{cmd:. scatter mpg weight, xlabel(,grid)}
	  {it:({stata "gr_example auto: scatter mpg weight, xlabel(,grid)":click to run})}
{* graph scatter5}{...}

{pstd}
In the above example, the grid lines are placed at the same values as the
default ticks and labels, but you can control that, too.
See 
{it:{help axis_label_options}}.


{marker remarks9}{...}
{title:Added lines}

{pstd}
Lines may be added to the graph for emphasis using the {it:added_line_options}
{cmd:yline()} and {cmd:xline()};
see 
{it:{help added_line_options}}.


{marker remarks10}{...}
{title:Axis range}

{pstd}
The extent or range of an axis is set according to all the things that appear
on it{hline 2}the data being plotted and the values on the axis being labeled
or ticked.  In the graph that just appeared above,

	{cmd:. sysuse auto, clear}

	{cmd:. scatter mpg weight}
	  {it:({stata "gr_example auto: scatter mpg weight":click to run})}
{* graph smpgweight}{...}

{pstd}
variable mpg varies between 12 and 41 and yet the {it:y} axis extends from 10
to 41.  The axis was extended to include 10<12 because the value 10 was
labeled.  Variable weight varies between 1,760 and 4,840; the {it:x} axis
extends from 1,760 to 5,000.  This axis was extended to include 5,000>4,840
because the value 5,000 was labeled.

{pstd}
You can prevent axes from being extended by specifying the
{cmd:ylabel(minmax)} and {cmd:xlabel(minmax)} options.  {cmd:minmax} specifies
that only the minimum and maximum are to be labeled:

{phang2}
	{cmd:. scatter mpg weight, ylabel(minmax) xlabel(minmax)}
{p_end}
	  {it:({stata "gr_example auto: scatter mpg weight, ylabel(minmax) xlabel(minmax)":click to run})}
{* graph scatter6}{...}

{pstd}
In other cases, you may wish to widen the range of an axis.  This you can
do by specifying the {cmd:range()} descriptor of the {it:axis_scale_options}
{cmd:yscale()} or {cmd:xscale()}.  For instance,

{phang2}
	{cmd:. scatter mpg weight, xscale(range(1000 5000))}

{pstd}
would widen the {it:x} axis to include 1,000 to 5,000.  We typed out the
name of the option, but most people would type

{phang2}
	{cmd:. scatter mpg weight, xscale(r(1000 5000))}

{pstd}
{cmd:range()} can widen, but never narrow, the extent of an axis.  Typing

{phang2}
	{cmd:. scatter mpg weight, xscale(r(1000 4000))}

{pstd}
would not omit cars with {cmd:weight}>4000 from the plot.  If that is your
desire, type

	{cmd:. scatter mpg weight if weight<=4000}

{pstd}
See 
{it:{help axis_scale_options}} for more information on {cmd:range()},
{cmd:yscale()}, and {cmd:xscale()}; see 
{it:{help axis_label_options}} for more information on
{cmd:ylabel(minmax)} and {cmd:xlabel(minmax)}.


{marker remarks11}{...}
{title:Log scales}

{pstd}
By default, arithmetic scales for the axes are used.  Log scales can be
obtained by specifying the {cmd:log} suboption of
{cmd:yscale()} and {cmd:xscale()}.  For instance,

	{cmd:. sysuse lifeexp, clear}

	{cmd:. scatter lexp gnppc, xscale(log) xlab(,g)}
	  {it:({stata "gr_example lifeexp: scatter lexp gnppc, xscale(log) xlab(,g)":click to run})}
{* graph scatter7}{...}

{pstd}
The important option above is {cmd:xscale(log)}, which caused {cmd:gnppc}
to be presented on a log scale.

{pstd}
We included {cmd:xlab(,g)} (an abbreviated form of
{cmd:xlabel(,grid)}) to obtain {it:x} grid lines.

{pstd}
Note that the values 30,000 and 40,000 are overprinted.  We could improve
the graph by typing

	{cmd:. generate gnp000 = gnppc/1000}

{phang2}
	{cmd:. label var gnp000 "GNP per capita, thousands of dollars"}

{phang2}
	{cmd:. scatter lexp gnp000, xsca(log) xlab(.5 2.5 10(10)40, grid)}
{p_end}
	  {it:({stata "gr_example2 scatterlog":click to run})}
{* graph scatterlog}{...}

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


{marker remarks12}{...}
{title:Multiple axes}

{pstd}
Graphs may have more than one {it:y} axis and more than one {it:x} axis.
There are two reasons to do this:  you might include an extra axis so that you
have an extra place to label special values or so that you may plot multiple
variables on different scales.  In either case, specify the {cmd:yaxis()} or
{cmd:xaxis()} options.  See {it:{help axis_choice_options}}.


{marker remarks13}{...}
{title:Markers}

{pstd}
Markers are the ink used to mark where points are on the plot.
Many people think of markers in terms of their shape (circles, diamonds,
etc.), but they have other properties, including, most
importantly, their color and size.
The shape of the marker is specified by the {cmd:msymbol()}
option, its color by the {cmd:mcolor()} option, and its size by the
{cmd:msize()} option.

{pstd}
By default, solid circles are used for the first {it:y} variable, solid
diamonds for the second, solid squares for the third, and so on;
see {it:marker_options} under {hi:Options} for the remaining details, if you
care.  In any case, when you type

	{cmd:. scatter} {it:yvar} {it:xvar}

{pstd}
results are as if you typed

{phang2}
	{cmd:. scatter} {it:yvar} {it:xvar}{cmd:, msymbol(O)}

{pstd}
You can vary the symbol used by specifying other {cmd:msymbol()} arguments.
Similarly, you can vary the color and size of the symbol by specifying the
{cmd:mcolor()} and {cmd:msize()} options.
See {it:{help marker_options}}.

{pstd}
In addition to the markers themselves, you can request that the individual
points be labeled.  These marker labels are numbers or text that appear

⌨️ 快捷键说明

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