📄 legend_option.hlp
字号:
{smcl}
{* 05mar2005}{...}
{cmd:help legend_option}
{hline}
{* index legends}{...}
{* index keys}{...}
{* index legend() tt option}{...}
{title:Title}
{p2colset 5 26 28 2}{...}
{p2col :{hi:[G] {it:legend_option}} {hline 2}}Option for specifying legend{p_end}
{p2colreset}{...}
{title:Syntax}
{it:legend_option}{col 40}description
{hline 69}
{col 9}{...}
{cmdab:leg:end:(}[{it:contents}] [{it:location}]{cmd:)}{...}
{col 40}legend contents and location
{* --------------------------------}{...}
{hline 69}
{pin}
{cmd:legend()} is {it:merged-implicit}; see {help repeated options}.
{pstd}
where {it:contents} and {it:location} specify the contents
and the location of the legend.
{it:contents}{col 40}description
{hline 69}
{...}
{col 9}{...}
{cmd:order(}{it:orderinfo}{cmd:)}{...}
{col 40}which keys appear and their order
{...}
{col 9}{...}
{cmdab:lab:el:(}{it:labelinfo}{cmd:)}{...}
{col 40}override text for a key
{...}
{col 9}{...}
{cmdab:hol:es:(}{it:{help numlist}}{cmd:)}{...}
{col 40}positions in legend to leave blank
{col 9}{...}
{cmd:all}{...}
{col 40}generate keys for all symbols
{...}
{col 9}{...}
{cmdab:sty:le:(}{it:{help legendstyle}}{cmd:)}{...}
{col 40}overall style of legend
{...}
{col 9}{...}
{cmdab:c:ols:(}{it:#}{cmd:)}{...}
{col 40}{it:#} of keys per line
{...}
{col 9}{...}
{cmdab:r:ows:(}{it:#}{cmd:)}{...}
{col 40}or {it:#} of rows
{...}
{col 9}{...}
[{cmdab:no:}]{cmdab:colf:irst}{...}
{col 40}"1, 2, 3" in row 1 or in column 1?
{...}
{col 9}{...}
[{cmdab:no:}]{cmdab:textf:irst}{...}
{col 40}symbol-text or text-symbol?
{...}
{col 9}{...}
{cmdab:stac:k}{...}
{col 40}symbol/text vertically stacked
{col 9}{...}
{cmdab:rowg:ap:(}{it:{help relativesize}}{cmd:)}{...}
{col 40}gap between lines
{...}
{col 9}{...}
{cmdab:colg:ap:(}{it:{help relativesize}}{cmd:)}{...}
{col 40}gap between columns
{...}
{col 9}{...}
{cmdab:symp:lacement:(}{it:{help compassdirstyle}}{cmd:)}{...}
{col 40}alignment/justification of key's symbol
{...}
{col 9}{...}
{cmdab:keyg:ap:(}{it:{help relativesize}}{cmd:)}{...}
{col 40}gap between symbol-text
{...}
{col 9}{...}
{cmdab:symy:size:(}{it:{help relativesize}}{cmd:)}{...}
{col 40}height for key's symbol
{...}
{col 9}{...}
{cmdab:symx:size:(}{it:{help relativesize}}{cmd:)}{...}
{col 40}width for key's symbol
{...}
{col 9}{...}
{cmdab:textw:idth:(}{it:{help relativesize}}{cmd:)}{...}
{col 40}width for key's descriptive text
{...}
{col 9}{...}
{cmdab:forces:ize}{...}
{col 40}always respect {cmd:symysize()}, {cmd:symxsize()},
{col 40} and {cmd:textwidth()}
{...}
{col 9}{...}
{cmdab:bm:argin:(}{it:{help marginstyle}}{cmd:)}{...}
{col 40}outer margin around legend
{...}
{col 9}{...}
{it:{help textbox_options}}{...}
{col 40}other text characteristics
{...}
{col 9}{...}
{it:{help title_options}}{...}
{col 40}titles, subtitles, notes, captions
{...}
{col 9}{...}
{cmdab:r:egion:(}{it:roptions}{cmd:)}{...}
{col 40}borders and background shading
{hline 69}
{it:location}{col 40}description
{hline 69}
{col 9}{...}
{cmd:off} or {cmd:on}{...}
{col 40}suppress or force display of legend
{...}
{col 9}{...}
{cmdab:pos:ition:(}{it:{help clockposstyle}}{cmd:)}{...}
{col 40}where legend appears
{...}
{col 9}{...}
{cmd:ring(}{it:{help ringposstyle}}{cmd:)}{...}
{col 40}where legend appears (detail)
{...}
{col 9}{...}
{cmd:span}{...}
{col 40}"centering" of legend
{...}
{col 9}{...}
{cmd:at(}{it:#}{cmd:)}{...}
{col 40}allowed with {cmd:by()} only
{hline 69}
{pin}
See
{help legend_option##remarks3:Where legends appear} under {hi:Remarks} below,
and see {help title_options##remarks3:Positioning of titles} in
{it:{help title_options}} for definitions of {it:clockposstyle} and
{it:ringposstyle}.
{pstd}
{it:orderinfo}, the argument allowed by {cmd:legend(order())}, is
defined as
{phang2}
{c -(}{it:#}|{cmd:-}{c )-} [{cmd:"}{it:text}{cmd:"} {...}
[{cmd:"}{it:text}{cmd:"} ...]] [...]
{pstd}
{it:labelinfo}, the argument allowed by {cmd:legend(label())}, is
defined as
{phang2}
{it:#} {cmd:"}{it:text}{cmd:"} [{cmd:"}{it:text}{cmd:"} ...]
{pstd}
{it:roptions}, the arguments allowed by {cmd:legend(region())},
include
{it:roptions}{col 40}description
{hline 70}
{cmdab:sty:le:(}{it:{help areastyle}}{cmd:)}{...}
{col 40}overall style of region
{cmdab:c:olor:(}{it:{help colorstyle}}{cmd:)}{...}
{col 40}line + fill color of region
{cmdab:fc:olor:(}{it:{help colorstyle}}{cmd:)}{...}
{col 40}fill color of region
{cmdab:ls:tyle:(}{it:{help linestyle}}{cmd:)}{...}
{col 40}overall style of border
{cmdab:lc:olor:(}{it:{help colorstyle}}{cmd:)}{...}
{col 40}color of border
{cmdab:lw:idth:(}{it:{help linewidthstyle}}{cmd:)}{...}
{col 40}thickness of border
{cmdab:lp:attern:(}{it:{help linepatternstyle}}{cmd:)}{...}
{col 40}border pattern (solid, dashed, etc.)
{cmdab:m:argin:(}{it:{help marginstyle}}{cmd:)}{...}
{col 40}margin between border and contents of
{col 40} legend
{hline 70}
{title:Description}
{pstd}
The {cmd:legend()} option allows you to control the look, contents, and
placement of
the legend. A sample legend is
{c TLC}{hline 21}{c TRC}
{c |} o Observed {c |}
{c |} {hline 3} Linear fit {c |}
{c |} --- Quadratic fit {c |}
{c BLC}{hline 21}{c BRC}
{pstd}
The above legend has three {it:keys}. Each key is composed of a {it:symbol}
and {it:descriptive text} describing the symbol (whatever the symbol might be,
be it a marker, a line, or a color swatch).
{title:Option}
{phang}
{cmd:legend(}{it:contents}{cmd:,} {it:location}{cmd:)}
defines the contents of a legend, along with how it is to look,
and whether and where it is to be displayed.
{title:Content suboptions for use with legend()}
{phang}
{cmd:order(}{it:orderinfo}{cmd:)}
specifies which keys are to appear in the legend and the order in which
they are to appear.
{pmore}
{cmd:order(}{it:#} {it:#} ...{cmd:)} is the usual syntax.
{cmd:order(1 2 3)} would specify that key 1 is to appear first in the
legend, followed by key 2, followed by key 3. {cmd:order(1 2 3)} is the
default if there are three keys. If there were four keys,
{cmd:order(1 2 3 4)} would be the default, and so on. If there were four
keys and you specified {cmd:order(1 2 3)}, the fourth key would not
appear in the legend. If you specified {cmd:order(2 1 3)}, first key 2
would appear, followed by key 1, followed by key 3.
{pmore}
A dash specifies that text be inserted into the legend.
For instance, {cmd:order(1 2 - "}{it:text}{cmd:"} {cmd:3)} specifies
key 1 appear first, followed by key 2,
followed by the text {it:text}, followed by key 3.
Imagine that the default key were
{c TLC}{hline 19}{c TRC}
{c |} o Observed {c |}
{c |} {hline 3} linear {c |}
{c |} --- Quadratic {c |}
{c BLC}{hline 19}{c BRC}
{pmore}
Specifying {cmd:order(1 - "Predicted:" 2 3)} would produce
{c TLC}{hline 19}{c TRC}
{c |} o Observed {c |}
{c |} Predicted: {c |}
{c |} {hline 3} linear {c |}
{c |} --- Quadratic {c |}
{c BLC}{hline 19}{c BRC}
{pmore}
and specifying {cmd:order(1 - " " "Predicted:" 2 3)} would produce
{c TLC}{hline 19}{c TRC}
{c |} o Observed {c |}
{c |} {c |}
{c |} Predicted: {c |}
{c |} {hline 3} linear {c |}
{c |} --- Quadratic {c |}
{c BLC}{hline 19}{c BRC}
{pmore}
Note carefully the specification of a blank for the first line
of the text insertion; we typed {cmd:" "} and not {cmd:""}.
Typing {cmd:""} would insert nothing.
{pmore}
You may also specify quoted text after {it:#} to override the descriptive
text associated with a symbol. Specifying
{cmd:order(1 "Observed 1992" - " " "Predicted" 2 3)}
would change "Observed" in the above to "Observed 1992".
It is considered better style, however, to use the {cmd:label()}
suboption to relabel symbols.
{phang}
{cmd:label(}{it:#} {cmd:"}{it:text}{cmd:"} [{cmd:"}{it:text}{cmd:"} ...]{cmd:)}
specifies the descriptive text to be displayed next to the {it:#}th key.
Multiline text is allowed. Specifying
{cmd:label(1 "Observed 1992")} would change the descriptive text
associated with the first key to be "Observed 1992". Specifying
{cmd:label(1 "Observed" "1992-1993")} would change the descriptive text
to contain two lines, "Observed" followed by "1992-1993".
{pmore}
Note that the descriptive text of only one key may be changed
per {cmd:label()} suboption. Specify multiple {cmd:label()} suboptions
when you wish to change the text of multiple keys.
{phang}
{cmd:holes(}{it:numlist}{cmd:)}
specifies where gaps appear in the presentation of the keys.
{cmd:holes()} has an effect only if the keys are being presented in more
than one row and more than one column.
{pmore}
Consider a case in which the default key is
{c TLC}{hline 47}{c TRC}
{c |} o Observed {hline 3} Linear fit {c |}
{c |} --- Quadratic fit {c |}
{c BLC}{hline 47}{c BRC}
{pmore}
Specifying {cmd:holes(2)} would result in
{c TLC}{hline 47}{c TRC}
{c |} o Observed {c |}
{c |} {hline 3} Linear fit --- Quadratic fit {c |}
{c BLC}{hline 47}{c BRC}
{pmore}
In this case, {cmd:holes(2)} would have the same effect as specifying
{cmd:order(1 - " " 2 3)}, and as a matter of fact, there is always
an {cmd:order()} command that will achieve the same result as
{cmd:holes()}. {cmd:order()} has the added advantage of working in
all cases.
{phang}
{cmd:all}
specifies that keys be generated for all the plots of the graph,
even when the same symbol is repeated. The default is to generate keys
only when the symbols are different, which is determined by the overall
style. For example, in
{cmd:. scatter ylow yhigh x, pstyle(p1 p1) || ...}
{pmore}
there would be only one key generated for the variables ylow and
yhigh because they share the style {cmd:p1}. That single key's
descriptive text would indicate that the symbol corresponded to both
variables. If, on the other hand, you typed
{phang3}
{cmd:. scatter ylow yhigh x, pstyle(p1 p1) legend(all) || ...}
{pmore}
then separate keys would be generated for ylow and yhigh.
{pmore}
In the above example, do not confuse our use of the {it:scatter_option}
{cmd:pstyle()} with {cmd:legend()}'s suboption {cmd:legend(style())}.
The {it:scatter_option} {cmd:pstyle()} sets the overall style for the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -