Stata 15 help for linestyle

[G-4] linestyle -- Choices for overall look of lines

Syntax

linestyle Description ------------------------------------------------------------------------- foreground borders, axes, etc., in foreground color grid grid lines minor_grid a lesser grid line or same as grid major_grid a bolder grid line or same as grid refline reference lines yxline yline() or xline() none nonexistent line

p1 - p15 used by first - fifteenth "line" plot p1bar - p15bar used by first - fifteenth "bar" plot p1box - p15box used by first - fifteenth "box" plot p1area - p15area used by first - fifteenth "area" plot p1solid - p15solid same as p1 - p15 but always solid

p1mark - p15mark markers for first - fifteenth plot p1boxmark - p15boxmark markers for outside values of box plots p1dotmark - p15dotmark markers for dot plots p1other - p15other "other" lines, such as spikes and range plots -------------------------------------------------------------------------

Other linestyles may be available; type

. graph query linestyle

to obtain the full list installed on your computer.

Description

linestyle sets the overall pattern, thickness, color and alignment of a line; see lines for more information.

linestyle is specified via options named

<object><l or li or line>style()

or

<l or li or line>style()

For instance, for connecting lines (the lines used to connect points in a plot) used by graph twoway function, the option is named lstyle():

. twoway function ..., lstyle(linestyle) ...

Sometimes you will see that a linestylelist is allowed:

. twoway line ..., lstyle(linestylelist) ...

A linestylelist is a sequence of linestyles separated by spaces. Shorthands are allowed to make specifying the list easier; see [G-4] stylelists.

Remarks

Remarks are presented under the following headings:

What is a line? What is a linestyle? You do not need to specify a linestyle Specifying a linestyle can be convenient What are numbered styles? Suppressing lines

What is a line?

Nearly everything that appears on a graph is a line, the exceptions being markers, fill areas, bars, and the like, and even they are outlined or bordered by a line.

What is a linestyle?

Lines are defined by the following attributes:

1. linepattern -- whether it is solid, dashed, etc.; see [G-4] linepatternstyle

2. linewidth -- how thick the line is; see [G-4] linewidthstyle

3. linecolor -- the color and opacity of the line; see [G-4] colorstyle

4. linealignment -- the alignment of the outline or border of markers, fill areas, bars, and boxes; see [G-4] linealignmentstyle

The linestyle specifies all of these attributes.

You do not need to specify a linestyle

The linestyle is specified in options named

<object><l or li or line>style(linestyle)

Correspondingly, the following other options are always available:

<object><l or li or line>pattern(linepatternstyle)

<object><l or li or line>width(linewidthstyle)

<object><l or li or line>color(colorstyle)

<object><l or li or line>align(linealignmentstyle)

Often the <object> prefix is not required.

You specify the linestyle when a style exists that is exactly what you want or when using another style would allow you to specify fewer changes to obtain what you want.

Specifying a linestyle can be convenient

Consider the command

. line y1 y2 x

Assume that you wanted the line for y2 versus x to be the same as y1 versus x. You might set the pattern, width, and color of the line for y1 versus x and then set the pattern, width, and color of the line for y2 versus x to be the same. It would be easier, however, to type

. line y1 y2 x, lstyle(p1 p1)

lstyle() is the option that specifies the style of connected lines. When you do not specify the lstyle() option, results are the same as if you specified

lstyle(p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15)

where the extra elements are ignored. In any case, p1 is one set of pattern, thickness, and color values; p2 is another set; and so on.

Say that you wanted y2 versus x to look like y1 versus x, except that you wanted the line to be green; you could type

. line y1 y2 x, lstyle(p1 p1) lcolor(. green)

There is nothing special about the linestyles p1, p2, ...; they merely specify sets of pattern, thickness, and color values, just like any other named linestyle. Type

. graph query linestyle

to find out what other line styles are available. You may find something pleasing, and if so, that is more easily specified than each of the individual options to modify the individual elements.

Also see Appendix: Styles and composite styles in [G-2] graph twoway scatter for more information.

What are numbered styles?

p1 - p15 are the default styles for connecting lines in all twoway graphs, for example, twoway line, twoway connected, and twoway function. p1 is used for the first plot, p2 for the second, and so on. Some twoway graphs do not have connecting lines.

p1bar - p15bar are the default styles used for outlining the bars on bar charts; this includes twoway bar charts and bar charts. p1bar is used for the first set of bars, p2bar for the second, and so on.

p1box - p15box are the default styles used for outlining the boxes on box charts. p1box is used for the first set of boxes, p2box for the second, and so on.

p1area - p15area are the default styles used for outlining the areas on area charts; this includes twoway area charts and twoway rarea. p1area is used for the first filled area, p2area for the second, and so on.

p1solid - p15solid are the same as p1 - p15, but the lines are always solid; they have the same color and same thickness as p1 - p15.

p1mark - p15mark are the default styles for lines used to draw markers in all twoway graphs, for example, twoway scatter, twoway connected, and twoway rcapsym. p1mark is used for the first plot, p2mark for the second, and so on.

The linepatternstyle attribute is always ignored when drawing symbols.

p1boxmark - p15boxmark are the default styles for drawing the markers for the outside values on box charts. p1box is used for the first set of dots, p2box for the second, and so on.

p1dotmark - p15dotmark are the default styles for drawing the markers on dot charts. p1dot is used for the first set of dots, p2dot for the second, and so on.

p1other - p15other are the default styles used for "other" lines for some twoway plottypes, including the spikes for twoway spike and twoway rspike and the lines for twoway dropline, twoway rcap, and twoway rcapsym. p1other is used for the first set of lines, p2other for the second, and so on.

The "look" defined by a numbered style, such as p1, p1mark, p1bar, etc. -- by "look" we mean width (see [G-4] linewidthstyle), color (see [G-4] colorstyle), and pattern (see [G-4] linepatternstyle -- is determined by the scheme (see [G-4] schemes intro) selected.

Numbered styles provide default "looks" that can be controlled by a scheme. They can also be useful when you wish to make, say, the second "thing" on a graph look like the first. See Specifying a linestyle can be convenient above for an example.

Suppressing lines

Sometimes you want to suppress lines. For instance, you might want to remove the border around the plot region. There are two ways to do this: You can specify

<object><l or li or line>style(none)

or

<object><l or li or line>color(color)

The first usually works well; see Suppressing the axes in [G-3] axis_scale_options for an example.

For the outlines of solid objects, however, remember that lines have a thickness. Removing the outline by setting its line style to none sometimes makes the resulting object seem too small, especially when the object was small to begin with. In those cases, specify

<object><l or li or line>color(color)

and set the outline color to be the same as the interior color.


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index