-------------------------------------------------------------------------------
help for onewayplot
-------------------------------------------------------------------------------

Oneway dot plots

onewayplot varlist [if exp] [in range] [ , vertical width(#) stack height(#) { centre | center } variablelabels plot(plot) graph_options ]

onewayplot varname [if exp] [in range] [ , by(byvar) vertical width(#) stack height(#) { centre | center } plot(plot) graph_options ]

Description

onewayplot plots data as a series of marks against a single magnitude axis. By default this axis is horizontal. With the option vertical it is vertical.

Remarks

onewayplot differs from gr7, oneway and dotplot:

onewayplot may have either horizontal or vertical magnitude axis. With gr7, oneway the magnitude axis is always horizontal. With dotplot the magnitude axis is always vertical.

onewayplot and dotplot put descriptive text on the axes. gr7, oneway puts descriptive text under each line of marks.

onewayplot and dotplot allow any marker symbol to be used for the data marks. gr7, oneway always shows data marks as short vertical bars, unless jitter() is specified.

onewayplot and dotplot interpret jitter() in the same way as does scatter. gr7, oneway interprets jitter() as replacing short vertical bars by sets of dots.

onewayplot and dotplot allow tuning of xlabel(). gr7, oneway does not allow such tuning: the minimum and maximum are always shown. Similarly, onewayplot and dotplot allow the use of xline() and yline().

onewayplot and dotplot use by default only one colour in the body of the graph. gr7, oneway uses several colours with several variables.

There is no equivalent with onewayplot or dotplot to gr7, oneway rescale, which stretches each set of data marks to extend over the whole horizontal range of the graph.

onewayplot and dotplot with option by(byvar) do not require data to be sorted by byvar. gr7, oneway by(byvar) requires this.

onewayplot and dotplot with option by(byvar) do take the values of byvar literally. gr7, oneway by(byvar) does not take the values of byvar literally: displays for values 1, 2 and 4 will appear equally spaced.

onewayplot with the stack option produces a variant on dotplot. There is by default no binning of data: compare dotplot, nogroup. Binning may be accomplished with the width() option so that classes are defined by width * floor(varname/width): contrast dotplot, ny().

onewayplot has no options for showing means, means +/- SDs, medians or quartiles, in contrast to gr7, oneway box or dotplot.

Similar plots under a variety of names go back at least as far as Langren (1644): see Tufte (1997, p.15). Wilkinson (1999) gives several further references of historical interest. Chambers et al. (1983) used the term one-dimensional scatter plots. The term oneway plots appears to have been introduced by Computing Resource Center (1985) and the term strip plots appears traceable to work by J.W. and P.A. Tukey. Wild and Seber (2000) show many interesting examples of oneway plots.

Options

by(byvar) specifies that values of varname are to be shown separately by groups defined by byvar. This option may only be specified with a single variable. If stack is also specified, then note that distinct values of any numeric byvar are assumed to differ by at least 1. height() or the prior use of egen, group() label will fix any problems. See help on egen if desired.

width(#) specifies that values are to be rounded in classes of specified width. Classes are defined by width * floor(varname/width).

vertical specifies that the magnitude axis should be vertical.

stack specifies that data points with identical values are to be stacked, as in dotplot, except that by default there is no binning of data.

height(#) controls the amount of graph space taken up by stacked data points under the stack option above. The default is 0.8. This option will not by itself change the appearance of a plot for a single variable. Note that the height may need to be much smaller or much larger than 1 with by(), given that the latter takes values literally. For example, if your classes are 0(45)360, 36 might be a suitable height.

centre or center centres or centers marks for each variable or group on a hidden line.

variablelabels specifies that multiple variables be labelled by their variable labels. The default is to use variable names.

plot(plot) provides a way to add other plots to the generated graph; see help plot_option.

graph_options are options of scatter.

Examples

. onewayplot mpg . onewayplot mpg, by(foreign) . onewayplot mpg, by(foreign) vertical . onewayplot mpg, by(foreign) vertical stack . onewayplot mpg, by(foreign) vertical stack h(0.4)

. gen pipe = "|" . onewayplot mpg, ms(none) mlabpos(0) mlabel(pipe) mlabsize(*2) stack

. onewayplot price, by(rep78) w(200) stack h(0.4)

. egen median = median(mpg), by(rep78) . egen loq = pctile(mpg), by(rep78) p(25) . egen upq = pctile(mpg), by(rep78) p(75) . gen rep78_2 = rep78 - 0.2 . onewayplot mpg, by(rep78) stack h(0.5) plot(scatter rep78_2 median || rcap upq loq rep78_2, hor legend(off) xtitle("Mileage (mpg)"))

. egen mean = mean(mpg), by(rep78) . gen lb = . . gen ub = . . qui forval i = 1/5 { . ci mpg if rep78 == `i' . replace lb = r(lb) if rep78 == `i' . replace ub = r(ub) if rep78 == `i' . } . gen rep78_4 = rep78 + 0.4 . onewayplot mpg, by(rep78) stack h(0.25) plot(scatter rep78_4 mean || rcap ub lb rep78_4, hor legend(off) xtitle("Mileage (mpg)"))

Acknowledgements

Philip Ender helpfully identified a bug.

Author

Nicholas J. Cox, University of Durham, U.K. n.j.cox@durham.ac.uk

References

Chambers, J.M., W.S. Cleveland, B. Kleiner and P.A.Tukey. 1983. Graphical methods for data analysis. Belmont, CA: Wadsworth.

Computing Resource Center. 1985. STATA/Graphics User's Guide. Los Angeles, CA: Computing Resource Center.

Langren, Michael Florent van. 1644. La verdadera longitud por mar y tierra. Antwerp.

Tufte, E.R. 1997. Visual explanations: images and quantities, evidence and narrative. Cheshire, CT: Graphics Press.

Wild, C.J. and G.A.F. Seber. 2000. Chance encounters: a first course in data analysis and inference. New York: John Wiley.

Wilkinson, L. 1999. Dot plots. American Statistician 53: 276-281.

Also see

On-line: help for dotplot, gr7oneway, histogram