help for fabplot

Plots for each subset with rest of the data as backdrop

fabplot
command
yvar
xvar
[if]
[in]
,
by(byvar [, byopts])
[
select(condition)
front(twoway_command)
frontopts(twoway_options)
graph_options
]

Description

fabplot produces an array of scatter or other twoway
plots for yvar versus xvar according to a further variable
byvar. There is one plot for observations for each distinct subset
of byvar in which data for that subset are highlighted (shown at
the front or in the foreground, as it were) and the rest of the data
are shown as backdrop. The name fabplot can thus be understood as
indicating a plot showing some observations in each panel in the
front or as foreground and the others as backdrop or
background.

fabplot does not attempt to trap calls to twoway that are legal
with two numeric variables, but will not be helpful with its design. It is most
obviously useful with calls to scatter, line and connected
and written with those subcommands in mind.

Remarks

This approach was discussed in Cox (2010). See also Cox (2019) for wider
discussion of the spaghetti problem. The term spaghetti appears in Zelazny
(1985, 2001): this detail updates Cox (2019).

Cleveland (1985, pp.74, 203, 205, 268) shows graphs in which summary curves
for groups are repeated with data shown separately for each group.
(Note: these graphs do not appear in Cleveland 1994.)
Wallgren et al. (1996, pp.47, 69) use the same idea.

See also Zelazny (1985, 2001) for related ideas.

See for direct examples
Koenker (2005),
Carr and Pickle (2010),
Yau (2013),
Rougier et al. (2014),
Schwabish (2014, 2017),
Knaflic (2015),
Unwin (2015),
Berinato (2016),
Cairo (2016),
Camões (2016),
Standage (2016),
Kriebel and Murray (2018),
Grant (2019),
Koponen and Hildén (2019)
and Tufte (2020)
for examples.

Good journalism examples include The Guardian 6 February 2021
and The Economist April 10th 2021.

Readers knowing interesting or useful examples or
discussions, especially early in date or comprehensive in detail,
are welcome to email the author.

Options

by() specifies a numeric or string variable byvar defining
the distinct subsets being plotted. This is a required option. Options
of by() may be specified in the usual way: see by option.

select() specifies a true-or-false condition, such as one referring to byvar,
selecting which panels are shown. This is best explained with a concrete
example. You have 10 companies, but wish to display only panels for the
4 most interesting or important, but in each case data for the other 9 companies
should be shown as backdrop. Note that a standard if qualifier cannot
match this mix of choices.

front(twoway_command) specifies a twoway
command used to plot observations in each distinct subset as front or
foreground.

frontopts(twoway_options) specifies options of
twoway tuning the front or foreground plot of each distinct subset.

graph_options are options of twoway used to display
observations for the rest of the data in each plot.

Examples

. set scheme s1color

. set more on

. sysuse auto, clear

. fabplot scatter mpg weight, by(rep78)

. more

. fabplot scatter mpg weight, frontopts(ms(none) mla(rep78) mlabsize(*1.5) mlabpos(0) mlabcolor(blue)) by(rep78)

. more

. webuse grunfeld

. fabplot line invest year, by(company) ysc(log) yla(1 10 100 1000)

. more

. fabplot line invest year, by(company) ysc(log) yla(1 10 100 1000) front(connect) frontopts(mc(blue) lc(blue))

. more

. fabplot line invest year, by(company) ysc(log) yla(1 10 100 1000) frontopts(lw(thick)) select(company <= 4)

. use http://www.stata-journal.com/software/sj10-4/gr0046/windspeed.dta, clear

. egen rank = rank(windspeed), by(place) unique

. egen count = count(windspeed), by(place)

. generate pp = (rank - 0.5)/ count

. label variable pp "fraction of data"

. generate gumbel = -ln(-ln(pp))

. label var gumbel "Gumbel reduced variate"

. fabplot scatter windspeed gumbel, by(place)

Author

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

n.j.cox@durham.ac.uk

References

Berinato, S. 2016.
Good Charts: The HBR Guide to Making Smarter, More Persuasive Data Visualizations.
Boston, MA: Harvard Business Review Press. See p.74.

Cairo, A. 2016.
The Truthful Art: Data, Charts, and Maps for Communication.
San Francisco, CA: New Riders. See p.211.

Camões, J. 2016.
Data at Work: Best Practices for Creating Effective Charts and Information Graphics in Microsoft Excel.
San Francisco, CA: New Riders. See p.354.

Carr, D.B. and L.W. Pickle. 2010.
Visualizing Data Patterns with Micromaps.
Boca Raton, FL: CRC Press. See p.85.

Cleveland, W.S. 1985. Elements of Graphing Data.
Monterey, CA: Wadsworth.

Cleveland, W.S. 1994. Elements of Graphing Data.
Summit, NJ: Hobart Press.

Cox, N.J. 2010. Graphing subsets.
Stata Journal 10: 670-681.
https://www.stata-journal.com/sjpdf.html?articlenum=gr0046

Cox, N.J. 2019.
Some simple devices to ease the spaghetti problem.
Stata Journal 19: 989-1008.
https://journals.sagepub.com/doi/10.1177/1536867X19893641

Grant, R. 2019.
Data Visualization: Charts, Maps, and Interactive Graphics.
Boca Raton, FL: CRC Press. See p.52.

Knaflic, C.N. 2015.
Storytelling with Data: A Data Visualization Guide for Business Professionals.
Hoboken, NJ: John Wiley. See p.233.

Koenker, R. 2005.
Quantile Regression.
Cambridge: Cambridge University Press. See pp.12-13.

Koponen, J. and Hildén, J. 2019.
The Data Visualization Handbook.
Espoo: Aalto ARTS Books. See p.101.

Kriebel, A. and Murray, E. 2018.
#MakeoverMonday: Improving How We Visualize and Analyze Data, One Chart at a Time.
Hoboken, NJ: John Wiley. See p.303.

Rougier, N.P., Droettboom, M. and Bourne, P.E. 2014.
Ten simple rules for better figures.
PLOS Computational Biology 10(9): e1003833.
doi:10.1371/journal.pcbi.1003833
http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003833

Schwabish, J.A. 2014. An economist's guide to visualizing data.
Journal of Economic Perspectives 28: 209-234.
https://pubs.aeaweb.org/doi/pdfplus/10.1257/jep.28.1.209

Schwabish, J. 2017.
Better Presentations: A Guide for Scholars, Researchers, and Wonks.
New York: Columbia University Press. See p.98.

Standage, T. 2016.
Go Figure: The Economist Explains: Things You Didn't Know You Didn't Know.
London: Profile Books. See p.177.

Tufte, E.R. 2020.
Seeing with Fresh Eyes: Meaning, Space, Data, Truth.
Cheshire, CT: Graphics Press.
See p.26.

Unwin, A. 2015.
Graphical Data Analysis with R.
Boca Raton, FL: CRC Press. See pp.121, 217.

Wallgren, A., B. Wallgren, R. Persson, U. Jorner, and J.-A. Haaland.
1996.
Graphing Statistics and Data: Creating Better Charts.
Newbury Park, CA: SAGE. See pp.47, 69.

Wickham, H. 2016.
ggplot2: Elegant Graphics for Data Analysis.
Cham: Springer. See p.157.

Yau, N. 2013.
Data Points: Visualization That Means Something.
Indianapolis, IN: John Wiley. See p.224.

Zelazny, G. 1985.
Say It With Charts: The Executive's Guide to Successful Presentations.
Homewood, IL: Dow Jones-Irwin. See p.39 for a graph with four panels: series A compared in turn with series B, C, D, E. See also p.111.

Zelazny, G. 2001. Say It With Charts: The Executive's Guide to Visual Communication.
New York: McGraw-Hill. Same pages in this 4th edition:
see p.39 for a graph with four panels: series A compared in turn with series B, C, D, E. See also p.111.

Also see

On-line: help for twoway, help for graph matrix,
help for graph combine