multipanel plotting in r
play

Multipanel plotting in R with base graphics Sean Anderson Nov - PowerPoint PPT Presentation

Multipanel plotting in R with base graphics Sean Anderson Nov 2011 scanders@sfu.ca Compared to what? - Tufte by hand ggplot2 lattice par(mfrow) layout() split.screen() par(mfrow) par(mfrow) John et al. 1988, Science, 239, p162 and


  1. Multipanel plotting in R with base graphics Sean Anderson Nov 2011 scanders@sfu.ca

  2. Compared to what? - Tufte

  3. by hand ggplot2 lattice

  4. par(mfrow) layout() split.screen()

  5. par(mfrow)

  6. par(mfrow) John et al. 1988, Science, 239, p162 and reprinted in Tufte, Envisioning Information, p78

  7. ฀฀�฀฀����������฀฀฀���฀ ฀ ฀ par(mfrow) gure 1. Beanplots of potential correlates of extinction risk for five groups of vertebrate species in Canada. The short vertical lines Anderson et al. 2011, Bioscience, 61, p538

  8. par(mfrow) a b c d e f ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● g h i j ● k l ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● log(variance) ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● m n o p q r ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● s t u v w ● x ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● log(mean) Anderson et al. In Prep.

  9. layout()

  10. layout() 20000 USA − Maine (a) (b) 60 Canada − East Chile Mexico 15000 Distance from Hong Kong (km) 50 USA − Cali fornia USA − Washington State Time to peak (years) Canada − West 40 US − Alaska Republic of Korea 10000 Tanzania 30 Egypt Tanzania Fiji Solomon Islands Madagascar Malaysia Madagascar New Caledonia 20 Indonesia Australia 5000 Solomon Islands USA − Cali fornia Maldives Papua New Guinea Papua New Guinea Sri Lanka Japan 10 USA − Washington State New Caledonia Fiji Australia Republic of Korea Indonesia Philippines Seychelles Malaysia M e x i c o Philippines Egypt Maldives 0 0 1950 1960 1970 1980 1990 2000 1950 1960 1970 1980 1990 2000 Year that recent fishery began (c) 2000 Year that recent fishery began 1990 1980 1970 1960 1950 Anderson et al. 2011, Fish. Fish, 12, p317

  11. layout() 20000 USA − Maine (a) (b) 60 Canada − East Chile Mexico 15000 Distance from Hong Kong (km) 50 USA − Cali fornia USA − Washington State Time to peak (years) Canada − West 40 US − Alaska Republic of Korea 10000 Tanzania 30 Egypt 1 2 Tanzania Fiji Solomon Islands Madagascar Malaysia Madagascar New Caledonia 20 Indonesia Australia 5000 Solomon Islands USA − Cali fornia Maldives Papua New Guinea Papua New Guinea Sri Lanka Japan 10 USA − Washington State New Caledonia Fiji Australia Republic of Korea Indonesia Philippines Seychelles Malaysia M e x i c o Philippines Egypt Maldives 0 0 1950 1960 1970 1980 1990 2000 1950 1960 1970 1980 1990 2000 Year that recent fishery began (c) 2000 Year that recent fishery began 1990 3 1980 1970 1960 1950 Anderson et al. 2011, Fish. Fish, 12, p317

  12. layout() Eastern Newfoundland Souther n Gulf of St. L awrence Northern Newfoundland Western Cape Breton Norther n Gulf of St. L awrence 400 25 1500 1500 400 SPA (1000 t) SPA (1000 t) SPA (1000 t) RS (1000 t) SPA (1000 t) 20 300 300 1000 1000 15 Cod 200 200 10 500 500 100 100 5 0 0 0 0 0 Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) 15 60 15 80 20 Crab 10 40 60 10 40 10 5 20 5 20 5 0 0 0 0 0 Temperature � � � C � 1.5 0.0 2.5 2.5 2.0 1.0 2.0 −0.5 1.5 1.0 0.5 1.5 −1.0 1.0 0.0 0.5 0.0 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 Eastern Scotian Shelf Northern Cape Breton Southern Newfoundland Gulf of Maine Flemish Cap 40 40 SPA (1000 t) RS/SPA (1000 t) RS (Biomass index) SPA (1000 t) SPA (1000 t) 3.0 150000 40 30 30 30 2.0 Cod 20 20 20 50000 1.0 10 10 10 0.0 0 0 0 0 Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) RS (kg/trap) RS (t) 100 0.008 15 150 80 Crab 60 10 100 60 0.004 40 5 50 20 20 0.000 0 0 0 0 Temperature � � � C � 6 3.5 11 3.5 5 3.0 6.5 9 4 2.5 2.5 8 5.5 3 7 2.0 2 6 4.5 1.5 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 Year Boudreau et al. 2011, MEPS, 429, p169

  13. layout() 31 33 35 37 39 Eastern Newfoundland Souther n Gulf of St. L awrence Northern Newfoundland Western Cape Breton Norther n Gulf of St. L awrence 400 25 1500 1500 400 SPA (1000 t) SPA (1000 t) SPA (1000 t) RS (1000 t) SPA (1000 t) 20 300 300 1000 1000 15 Cod 1 4 7 10 13 200 200 10 500 500 100 100 5 0 0 0 0 0 Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) 15 60 15 80 20 Crab 10 2 5 8 11 14 40 60 10 40 10 5 20 5 20 5 0 0 0 0 0 Temperature � � � C � 1.5 0.0 2.5 2.5 2.0 1.0 2.0 3 6 9 12 15 −0.5 1.5 1.0 0.5 1.5 −1.0 1.0 0.0 0.5 0.0 32 34 36 38 40 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 41 43 45 47 49 Eastern Scotian Shelf Northern Cape Breton Southern Newfoundland Gulf of Maine Flemish Cap 40 40 SPA (1000 t) RS/SPA (1000 t) RS (Biomass index) SPA (1000 t) SPA (1000 t) 3.0 150000 40 30 30 30 2.0 Cod 16 19 22 25 28 20 20 20 50000 1.0 10 10 10 0.0 0 0 0 0 Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) Commercial CPUE (kg/trap) RS (kg/trap) RS (t) 100 0.008 15 150 80 Crab 17 20 23 26 29 60 10 100 60 0.004 40 5 50 20 20 0.000 0 0 0 0 Temperature � � � C � 6 3.5 11 3.5 5 3.0 6.5 18 21 24 27 30 9 4 2.5 2.5 8 5.5 3 7 2.0 2 6 4.5 1.5 42 44 46 48 50 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 1970 1980 1990 2000 2010 Year Boudreau et al. 2011, MEPS, 429, p169

  14. split.screen()

  15. split.screen() Taylor et al. 1982, J. Anim. Ecol., 51, p879

  16. split.screen() (a) Original (b) Original static method 100 Collapsed or closed 80 Overexploited 60 Fully exploited 40 Developing 20 Percentage of fisheries 0 (c) Revised (d) Revised rob ust−dynamic method 100 80 60 40 20 0 1960 1970 1960 1970 1980 1990 2000 Year Anderson et al. In Review

  17. split.screen() 4.0 4.0 4.5 a Eastern Bering Sea f Northeast USA k Canary Current 24 1 12 9 3.5 3.5 4.0 10 2 13 4.5 l Benguela Current b Gulf of Alaska 3.5 25 4.0 11 4 4.0 5 3.0 3.5 3.5 2.5 3.0 g Scotian Shelf 3.0 3 14 4.0 15 c California Current m Gulf of Thailand 3.5 26 4.0 3.5 6 Mean trophic level 3.0 3.5 3.0 n Northwest Australia 4.0 4.5 h Newfoundland − Labrador 27 1718 3.0 16 3.5 4.0 d Gulf of Mexico 7 3.5 3.0 3.5 8 3.0 o Southeast Australia 4.0 3.0 2.5 3.5 i North Sea e Southeast USA 19 4.0 4.0 20 4.5 p New Zealand 3.5 28 21 3.5 29 4.0 4.0 j Celtic − Biscay 3.0 23 3.5 3.5 22 2.5 1950 1965 1980 1995 1950 1965 1980 1995 1950 1965 1980 1995 Year Branch et al. 2010, Nature, 468, p431

  18. split.screen() r = − 0.1 r = 0 r = 0.1 1.5 a b c k = 2 0.5 1.5 d e f k = 16 0.5 Portfolio effect r = − 0.5 r = 0 r = 0.5 g h i 1.0 µ 2 µ 1 = 1 0.5 j k l µ 2 µ 1 = 16 1.0 0.5 1.0 1.5 2.0 2.5 1.0 1.5 2.0 2.5 1.0 1.5 2.0 2.5 Taylor's power law z − value Anderson et al. In Prep.

  19. split.screen() 0, 1 1, 1 0, 0.46 0.35, 0.44 0.37, 0.44 0.72, 0.44 0.75, 0.44 1, 0.46 0, 0.43 1, 0.44 0, 0 0.34, 0 0.37, 0 0.72, 0 0.75, 0 1, 0

  20. split.screen() 0, 1 1, 1 0, 0.46 0.35, 0.44 0.37, 0.44 0.72, 0.44 0.75, 0.44 1, 0.46 0, 0.43 1, 0.44 0, 0 0.34, 0 0.37, 0 0.72, 0 0.75, 0 1, 0 http://xkcd.com/323/

  21. split.screen() http://xkcd.com/323/

Recommend


More recommend