lecture 8: tables, text annotations, mathematical expressions, legends, custom axes trevor a. branch...

23
Lecture 8: tables, text annotations, mathematical expressions, legends, custom axes Trevor A. Branch [email protected] Beautiful graphics in R, FISH507H SAFS, University of Washington

Upload: violet-mesman

Post on 14-Dec-2015

221 views

Category:

Documents


4 download

TRANSCRIPT

Lecture 8: tables, text annotations, mathematical expressions, legends, custom

axes

Trevor A. [email protected]

Beautiful graphics in R, FISH507HSAFS, University of Washington

Spring quarter classes in R

• I run FISH458 on solving real-life conservation problems through fitting models to data (R coding required, FISH454 helpful, 4 credits)

• New class FISH512 Super-Advanced R run by my lab on structured programming, speeding up R, including C++ code, dplyr, ggplot2, object-oriented code, creating R packages, and GitHub (2 credits).

Reminder

Project drafts due in class 10 March for all figures. There will be a series of “speed-

reviewing” small groups for feedback from classmates. For best results, make sure your

plots are as complete and perfect as possible.

Creator, Paul Butler: “When I tell people I used R, the reaction I get is roughly what I would expect if I told them I made it with Microsoft Paint and a bottle of Jägermeister.” Plotted from most to least connected cities in order (overplotting), and used colorRampPalette(c("black","blue","white")) to plot more connected cities in whiter color. Transparent colors did not work: too many lines and minimum transparency not enough. Random sample of 10 million pairs of friends.

http://paulbutler.org/archives/visualizing-facebook-friends/

Tables vs. figures

• Day (1998) “How to write and publish a scientific paper” Oryx Press, Phoenix, AZ.

• Tufte (1990) “Envisioning information” Cheshire, CT: Graphics Press

• Tufte (2006) “Beautiful evidence” Cheshire, CT: Graphics Press• Gelman, Andrew (2011). Why tables are really much better

than graphs. Journal of Computational and Graphical Statistics 20:3-7 [plus responses by William Briggs, Michael Friendly, Ernest Kwan, Howard Wainer, Graham Wills; and a rejoinder]

• Few (2004) “Show me the numbers” Analytics Press, Oakland, CA

Day (2006) How to write and publish a scientific paper, p. 65

Courtroom chart by reputed mobster John Gotti's lawyers, listing Government witnesses’ criminal activities.

Tufte (1990) Envisioning information, p. 31

Train timetables: 1396 numbers and periods

Tufte (1990) Envisioning information, p. 46-47

Train timetables: 619 characters (777 fewer)

Keihin Express Line, Yokohama Station, Sagami Tetsudo Company, 1985 timetable, p. 76Tufte (1990) Envisioning information, p. 46-47

Tufte redesignBrenner (2002)

Brenner (2002) The Lancet 360:1131-1135Tufte (2006) Beautiful evidence, p. 174

Tufte (2006) Beautiful evidence, p. 175

Gelman (2011)

“Graphs are gimmicks, substituting fancy displays for careful analysis and rigorous reasoning. It is basically a trade-off: the snazzier your

display, the more you can get away with a crappy underlying analysis. Conversely, a good analysis does not need a fancy graph to sell itself.

The best quantitative research has an underlying clarity and a substantive importance whose results are best presented in a sober, serious tabular display. And the best quantitative researchers trust their peers enough to present their estimates and standard errors

directly, with no tricks, for all to see and evaluate. Let us leave the dot plots, pie charts, moving zip charts, and all the rest to the folks in the marketing department and the art directors of Newsweek and USA

Today. As scientists we are doing actual research and we want to see, and present, the hard numbers.”

Gelman (2011) Journal of Computational and Graphical Statistics 20(1): 3-7

Friendly & Kwan (2011) Journal of Computational and Graphical Statistics 20(1): 18-27

Wills (2011) Journal of Computational and Graphical Statistics 20:28-35

Proportion of flights canceled by day of the year

Proportion of flights canceled by day of the year

Wills (2011) Journal of Computational and Graphical Statistics 20:28-35

Proportion of flights canceled by day of the year

Wills (2011) Journal of Computational and Graphical Statistics 20:28-35

Conditional formatting in Excel (under Home ribbon)

Day J F M A M J J A S O N D1 2.1% 2.3% 1.9% 1.5% 1.3% 1.4% 1.6% 1.8% 1.7% 1.0% 1.4% 2.1%2 3.2% 2.5% 2.5% 1.3% 1.4% 1.6% 1.3% 1.8% 1.5% 1.3% 1.3% 1.5%3 3.0% 2.7% 2.2% 1.6% 1.1% 1.3% 1.0% 1.7% 1.8% 1.1% 1.1% 1.6%4 3.2% 3.2% 2.8% 1.5% 1.2% 1.4% 0.9% 1.7% 2.1% 1.4% 1.1% 1.5%5 2.7% 3.0% 3.1% 1.1% 1.2% 1.3% 1.2% 1.6% 1.9% 1.6% 1.2% 2.3%6 3.6% 3.4% 3.5% 1.2% 1.3% 1.6% 1.4% 1.2% 1.9% 1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4% 1.5% 2.3% 1.0% 1.3% 2.7%24 1.8% 2.9% 1.1% 1.1% 1.4% 1.2% 1.4% 1.7% 1.7% 1.3% 1.1% 2.0%25 3.7% 3.4% 1.2% 1.2% 1.0% 1.6% 1.4% 1.6% 2.1% 1.5% 0.8% 2.3%26 3.0% 2.2% 1.2% 1.2% 0.8% 2.0% 1.7% 1.6% 2.0% 1.7% 0.8% 2.5%27 3.1% 1.4% 1.4% 0.9% 0.9% 2.2% 2.1% 1.4% 1.8% 1.4% 0.8% 2.3%28 2.7% 1.8% 1.3% 1.1% 0.8% 1.8% 2.0% 1.6% 1.4% 1.3% 0.9% 2.6%29 3.3% 1.3% 1.1% 0.9% 0.9% 1.6% 1.7% 1.9% 1.4% 1.1% 1.1% 2.3%30 2.8% 1.3% 1.3% 1.3% 1.4% 1.6% 2.0% 1.1% 1.2% 1.4% 2.9%31 2.3% 1.7% 1.3% 1.7% 1.9% 1.5% 2.2%

Text annotations

Tufte (2006) Beautiful evidence, p. 118Original: Sagan (1977) The dragons of Eden

Tufte (2006) Beautiful evidence, p. 119

Tufte (2006) Beautiful evidence, p. 120

Tufte (2006) Beautiful evidence, p. 120

Redrawn from Worm et al. (2009) Science 325:578-585

Redrawn from Worm et al. (2009) Science 325:578-585