help for crossplot

Scatter (or other twoway) plots for each y vs each x variable

crossplot
(yvarlist)
(xvarlist)
[weight]
[if]
[in]
[
,
allobs
graph_options
sequence(words_in_sequence)
seqopts(option)
combine(combine_options)
]

Weights are supported if and as allowed by the twoway plot requested.

Description

crossplot produces an array of scatter or other
twoway plots for yvarlist versus xvarlist. There is
one plot for each y variable from yvarlist and each x
variable from xvarlist. The name crossplot is intended to
signal cross-combination. Graphs are drawn individually and then
combined with graph combine.

Remarks

The indicated syntax is (yvarlist)
(xvarlist).

The actual syntax is more indulgent. The first token, a single variable
name or a wildcard varlist or a set of variable names in parentheses
(), is interpreted as yvarlist. Remaining variable names will
be interpreted as xvarlist, regardless of any parentheses.

yvarlist and xvarlist are combined using all possible pairs
with one y and one x, i.e. as a Cartesian product.

A neat arrangement of the individual graphs is produced if the number of
y variables is equal to the number of x variables, or the
number of y variables is 1, or the number of x variables is 1.
Otherwise, use combine() to tune the number of rows or columns in
the table of graphs.

This is a 2014 revision of cpyxplot (SSC) first made public in 1999.

Tufte (1983, 1990) remains inspirational on the value of "small
multiples". Heiberger and Holland (2004, 2008) contain enthusiastic
advocacy of Cartesian products in statistical graphics.

See combineplot (SSC) for a more general command in this
territory.

Options

allobs requests plotting of results on each graph for all possible
observations. The default is to show only observations for which all
y and all x variables are non-missing.

graph_options are options allowed with scatter.

Particular attention is drawn to recast(), which
specifies a twoway plottype that may be used to plot some y
versus some x. Possibilities include line and
connected.

sequence() specifies text to appear in sequence to act as captions
for each plot. For example, seq(a b c d) specifies that successive
graphs will be labelled a, b, c and d. The
precise syntax is that successive words of the argument will be
shown using the option
caption("word", pos(11) size(large)). As usual in
Stata, binding in double quotes " " is stronger than separation by
spaces, so syntax such as
seq("first caption" "second caption" "third caption" "fourth caption")
would show text with embedded spaces.

seqopts() specifies modification of the default display for
sequence(). For example, seqopts(caption(, color(red))
changes the text colour to red. Note that substantial changes are likely
to require use of the Graph Editor or your own syntax.

combine() specifies options allowed with graph combine.

Examples

. sysuse auto, clear

. gen rt_mpg = sqrt(mpg)

. gen ln_mpg = ln(mpg)

. gen rec_mpg = 100/mpg

. crossplot (mpg rt_mpg ln_mpg rec_mpg) weight, combine(imargin(small))

. use http://www.stata-press.com/data/r13/audiometric, clear

. crossplot (lft*) (rght*), jitter(1)

Author

Nicholas J. Cox, Durham University, U.K.

n.j.cox@durham.ac.uk

Acknowledgments

Rory Wolfe suggested the original problem.
Phil Ender alerted me to a bug.
Pete Watt made a helpful suggestion.

I salute Burt S. Holland
(1946-2010) and James Alexander Green (1926-2014), from whose
excellent little book (Green 1965) I first learned of Cartesian products
and many other such standard beasts.

References

Green, J.A. 1965.
Sets and groups.
London: Routledge and Kegan Paul.

Heiberger, R.M. and Holland, B. 2004.
Statistical analysis and data display: An intermediate course with examples in S-PLUS, R, and SAS.
New York: Springer.

Heiberger, R.M. and Holland, B. 2008.
Structured sets of graphs.
In Chen, C., Härdle, W. and Unwin, A. (Eds)
Handbook of data visualization.
Berlin: Springer, 415-445.

Tufte, E.R. 1983, 2nd edition 2001.
The visual display of quantitative information.
Cheshire, CT: Graphics Press.

Tufte, E.R. 1990.
Envisioning information.
Cheshire, CT: Graphics Press.

Also see

On-line: help for twoway, help for graph matrix,
help for combineplot (if installed from SSC),
help for cpcorr (if installed from SSC)