[G-3] connect_options -- Options for connecting data points with lines
Syntax
connect_options Description
-------------------------------------------------------------------------
connect(connectstyle) how to connect points
sort[(varlist)] how to sort before connecting
cmissing({y|n} ...) missing values are ignored
lpattern(linepatternstyle) line pattern (solid, dashed, etc.)
lwidth(linewidthstyle) thickness of line
lcolor(colorstyle) color and opacity of line
lalign(linealignmentstyle) line alignment (inside, outside, center)
lstyle(linestyle) overall style of line
pstyle(pstyle) overall plot style, including linestyle
recast(newplottype) advanced; treat plot as newplottype
-------------------------------------------------------------------------
All options are rightmost; see repeated options. If both sort and
sort(varlist) are specified, sort is ignored and sort(varlist) is
honored.
Description
The connect_options specify how points on a graph are to be connected.
In certain contexts (for example, scatter; see [G-2] graph twoway
scatter), the lstyle(), lpattern(), lwidth(), lcolor(), and lalign()
options may be specified with a list of elements, with the first element
applying to the first variable, the second element to the second
variable, and so on. For information about specifying lists, see [G-4]
stylelists.
Options
connect(connectstyle) specifies whether points are to be connected and,
if so, how the line connecting them is to be shaped; see [G-4]
connectstyle. The line between each pair of points can connect them
directly or in stairstep fashion.
sort and sort(varlist) specify how the data be sorted before the points
are connected.
sort specifies that the data should be sorted by the x variable.
sort(varlist) specifies that the data be sorted by the specified
variables.
sort is the option usually specified. Unless you are after a special
effect or your data are already sorted, do not forget to specify this
option. If you are after a special effect, and if the data are not
already sorted, you can specify sort(varlist) to specify exactly how
the data should be sorted.
Specifying sort or sort(varlist) when it is not necessary will slow
graph down a little. It is usually necessary to specify sort if you
specify the twoway option by(), and especially if you include the
suboption total.
Options sort and sort(varlist) may not be repeated within the same
plot.
cmissing({y|n} ...) specifies whether missing values are to be ignored.
The default is cmissing(y ...), meaning that they are ignored.
Consider the following data:
+------------+
| rval x |
|------------|
1. | .923 1 |
2. | 3.046 2 |
3. | 5.169 3 |
4. | . . |
5. | 9.415 5 |
|------------|
6. | 11.538 6 |
+------------+
Say that you graph these data by using "line rval x" or equivalently
"scatter rval x, c(l)". Do you want a break in the line between 3
and 5? If so, you code
. line rval x, cmissing(n)
or equivalently
. scatter rval x, c(l) cmissing(n)
If you omit the option (or code cmissing(y)), the data are treated as
if they contained
+------------+
| rval x |
|------------|
1. | .923 1 |
2. | 3.046 2 |
3. | 5.169 3 |
4. | 9.415 5 |
5. | 11.538 6 |
+------------+
meaning that a line will be drawn between (3, 5.169) and (5, 9.415).
If you are plotting more than one variable, you may specify a
sequence of y/n answers.
lpattern(linepatternstyle), lwidth(linewidthstyle), lcolor(colorstyle),
lalign(linealignmentstyle) and lstyle(linestyle) determine the look
of the line used to connect the points; see lines. Note the
lpattern() option, which allows you to specify whether the line is
solid, dashed, etc.; see [G-4] linepatternstyle for a list of
line-pattern choices.
pstyle(pstyle) specifies the overall style of the plot, including not
only the linestyle, but also all other settings for the look of the
plot. Only the linestyle affects the look of line plots. See [G-4]
pstyle for a list of available plot styles.
recast(newplottype) is an advanced option allowing the plot to be recast
from one type to another, for example, from a line plot to a
scatterplot; see [G-3] advanced_options. Most, but not all, plots
allow recast().
Remarks
An important option among all the above is connect(), which determines
whether and how the points are connected. The points need not be
connected at all (connect(i)), which is scatter's default. Or the points
might be connected by straight lines (connect(l)), which is line's
default (and is available in scatter). connect(i) and connect(l) are
commonly specified, but there are other possibilities such as connect(J),
which connects in stairstep fashion and is appropriate for empirical
distributions. See [G-4] connectstyle for a full list of your choices.
Equally as important as connect() is sort. If you do not specify this,
the points will be connected in the order in which they are encountered.
That can be useful when you are creating special effects, but, in
general, you want the points sorted into ascending order of their x
variable. That is what sort does.
The remaining connect options specify how the line is to look: Is it
solid or dashed? Is it red or green? How thick is it? Option
lpattern() can be of great importance, especially when printing to a
monochrome printer. For a general discussion of lines (which occur in
many contexts other than connecting points), see lines.