Stata 15 help for pstyle

[G-4] pstyle -- Choices for overall look of plot

Syntax

pstyle Description ------------------------------------------------------------------------- ci first plot used as confidence interval ci2 second plots used as confidence interval

p1 - p15 used by first to fifteenth "other" plot p1line - p15line used by first to fifteenth "line" plot p1bar - p15bar used by first to fifteenth "bar" plot p1box - p15box used by first to fifteenth "box" plot p1dot - p15dot used by first to fifteenth "dot" plot p1pie - p15pie used by first to fifteenth "pie" plot p1area - p15area used by first to fifteenth "area" plot p1arrow - p15arrow used by first to fifteenth "arrow" plot -------------------------------------------------------------------------

Other pstyles may be available; type

. graph query pstyle

to obtain a complete list of pstyles installed on your computer.

Description

A pstyle -- always specified in option pstyle(pstyle) -- specifies the overall style of a plot and is a composite of markerstyle; markerlabelstyle; areastyle; connected lines, linestyle, connectstyle; and the connect_option cmissing().

Remarks

Remarks are presented under the following headings:

What is a plot? What is a pstyle? The pstyle() option Specifying a pstyle What are numbered styles?

What is a plot?

When you type

. scatter y x

y versus x is called a plot. When you type

. scatter y1 x || scatter y2 x

or

. scatter y1 y2 x

y1 versus x is the first plot, and y2 versus x is the second.

A plot is one presentation of a data on a graph.

What is a pstyle?

The overall look of a plot -- the pstyle -- is defined by the following attributes:

1. The look of markers, including their shape, color, size, etc.; see [G-4] markerstyle

2. The look of marker labels, including the position, angle, size, color, etc.; see [G-4] markerlabelstyle

3. The look of lines that are used to connect points, including their color, width, and style (solid, dashed, etc.); see [G-4] linestyle

4. The way points are connected by lines (straight lines, stair step, etc.) if they are connected; see [G-4] connectstyle

5. Whether missing values are ignored or cause lines to be broken when the points are connected

6. The way areas such as bars or beneath or between curves are filled, colored, or shaded, including whether and how they are outlined; see [G-4] areastyle

7. The look of the "dots" in dot plots

8. The look of arrow heads

The pstyle specifies these seven attributes.

The pstyle() option

The pstyle is specified by the option

pstyle(pstyle)

Correspondingly, other options are always available to control each of the attributes; see, for instance, [G-2] graph twoway scatter.

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

Specifying a pstyle

Consider the command

. scatter y1 y2 x, ...

and further, assume that many options are specified. Now imagine that you want to make the plot of y1 versus x look just like the plot of y2 versus x: you want the same marker symbols used, the same colors, the same style of connecting lines (if they are connecting), etc. Whatever attributes there are, you want them treated the same.

One solution would be to track down every little detail of how the things that are displayed appear and specify options to make sure that they are specified the same. It would be easier, however, to type

. scatter y1 y2 x, ... pstyle(p1 p1)

When you do not specify the pstyle() option, results are the same as if you specified

pstyle(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 plot-appearance values, p2 is another set, and so on. So when you type

. scatter y1 y2 x, ... pstyle(p1 p1)

all the appearance values used for y2 versus x are the same as those used for y1 versus x.

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

. scatter y1 y2 x, ... pstyle(p1 p1) mcolor(. green)

There is nothing special about the pstyles p1, p2, ...; they merely specify sets of plot-appearance values just like any other pstyles. Type

. graph query pstyle

to find out what other plot styles are available.

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 all twoway graphs except twoway line charts, twoway bar charts, and twoway area charts. p1 is used for the first plot, p2 for the second, and so on.

p1line - p15line are the default styles used for line charts, including twoway line charts and twoway rline. p1line is used for the first line, p2line for the second, and so on.

p1bar - p15bar are the default styles used for bar charts, including 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 box charts. p1box is used for the first set of boxes, p2box for the second, and so on.

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

p1pie - p15pie are the default styles used for pie charts. p1pie is used for the first pie slice, p2pie for the second, and so on.

p1area - p15area are the default styles used for area charts, including twoway area charts and twoway rarea. p1area is used for the first filled area, p2area for the second, and so on.

p1arrow - p15arrow are the default styles used for arrow plots, including twoway pcarrow plots and twoway pcbarrow. p1arrow is used for the first arrow plot, p2arrow for the second, and so on.

The "look" defined by a numbered style, such as p1bar, p3, or p2area, is determined by the scheme selected. By "look" we mean such things as color, width of lines, or patterns used.

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 element on a graph look like the first. You can, for example, specify that markers for the second scatter on a scatterplot be drawn with the style of the first scatter by using the option pstyle(p1 p1). See Specifying a pstyle above for a more detailed example.


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