Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 5 advanced multipanel plots Trevor A. Branch Beautiful graphics in R, FISH554 SAFS, University of Washington.

Similar presentations


Presentation on theme: "Lecture 5 advanced multipanel plots Trevor A. Branch Beautiful graphics in R, FISH554 SAFS, University of Washington."— Presentation transcript:

1 Lecture 5 advanced multipanel plots Trevor A. Branch tbranch@uw.edu Beautiful graphics in R, FISH554 SAFS, University of Washington

2 Other visualization courses at UW INFO 424 Information Visualization and Aesthetics (Ostergren, Fall http://courses.washington.edu/info424/ ) http://courses.washington.edu/info424/ INFX 598E Information Visualization for Information Professionals (Ostergren, summer https://canvas.uw.edu/courses/891359 ) https://canvas.uw.edu/courses/891359 HCDE 411 Information Visualization (Aragon, uses Tableau, http://faculty.washington.edu/aragon/classes/hcde411/w13/ ) http://faculty.washington.edu/aragon/classes/hcde411/w13/ HCDE 508 Visual Media (Ostergren, http://www.hcde.washington.edu/courses ) http://www.hcde.washington.edu/courses HCDE 511 Information Visualization (Aragon, http://www.washington.edu/students/icd/S/hcde/511aragon.html ) http://www.washington.edu/students/icd/S/hcde/511aragon.html CSE 512 Information Visualization (Heer, uses D3, HTML, R, etc. http://courses.cs.washington.edu/courses/cse512/14wi/ ) http://courses.cs.washington.edu/courses/cse512/14wi/ DESIGN 478 Information Design (Cheng, limited to Design students, http://www.washington.edu/students/crscat/design.html ) http://www.washington.edu/students/crscat/design.html Note: HCDE=Human Centered Design & Engineering, INFO=Information School, CSE=Computer Science & Engineering, DESIGN=School of Art, division of Design

3 Five multipanel methods in base R Methods cannot be combined with each other par(mfrow) or par(mfcol) layout(mat, widths, widths) par(fig) par(plt) split.screen(figs)

4 par(mfrow) Every figure is the same size

5

6 layout(mat) Figures must be placed on a grid system; widths and heights can be adjusted; figures can occupy more than one grid rectangle; squares can be left blank

7 Branch et al. (2011) Conservation Biology 25:777-786 mat <- matrix(c(1,2), nrow=1, ncol=2) layout(mat=mat, widths=c(56, 29))

8 maxC <- apply(reven.data, MARGIN=2,max) mat <- matrix(1:8,nrow=4,ncol=2, byrow=T) par(mar=c(0,2.5,0,0), oma=c(5,2.5,4,1)) layout(mat=mat, widths=c(30,16),heights=30+maxC)

9 Worm et al. (2009) Science 325:578-585 mat=matrix(c(1,2,3,4,5, 6,7,8,9,10, 0,0,0,0,0, 11,11,11,11,11), nrow=5, ncol=4, byrow=F) layout(mat=mat, heights=c(1,1,1,1,1), widths=c(5,5,3,10)) par(oma=c(5,5,1,1),mar=c(0,0,0,0))

10 Branch et al. (2010) Nature 468:431-435 Main plot mat <- matrix(c(1,2,3,3), nrow=2, ncol=2, byrow=F) par(oma=c(1,2,1,11), mar=c(3,2,0,1)) layout(mat=mat, widths=c(2,1.3), heights=c(2.2,1)) Trickery for bottom-right “legend” par(xpd=NA) positions <- seq(from=2025,to=2060,length. out=5) ypos <- c(-0.34,0.66) #then commands for rect(), #arrows, axis(at=,pos=), #etc. par(xpd=T)

11 Source: Melissa Clarkson, http://students.washington.edu/mclarkso/

12

13 par(plt=c(0.4, 0.8, 0.2, 0.7)) par(plt) Individual figures are added anywhere and of any size, one at a time. Each plot border is defined as a vector of four values (0 to 1) with positions (left, right, bottom, top)

14 Source: Melissa Clarkson, http://students.washington.edu/mclarkso/ par(fig=c(0.4, 0.8, 0.2, 0.7)) par(fig) Individual figures are added anywhere and of any size, one at a time. Each figure border is defined as a vector of four values (0 to 1) with positions (left, right, bottom, top)

15 Using par(fig) and par(plt) Coordinates are given in normalized device space (from 0 to 1) and are specified by: c(left, right, bottom, top) a different order from par or oma 2. Plots can partially overlay other plots 3. Replacing fig= with plt= sets the plot border instead of the figure border Source: Melissa Clarkson, http://students.washington.edu/mclarkso/

16 par(fig=c(0.4,0.7,0.1,0.7)) plot(…) par(new=T) par(fig=c(0.1,0.3,0.05,0.65)) plot(…) par(new=T) par(fig=c(0.2,0.8,0.75,0.9)) plot(…) Figures at arbitrary (non-grid) locations using fig

17 mat <- matrix(c(0.0, 0.1, 0.9, 1.0, 0.0, 0.3, 0.7, 1.0, 0.1, 0.6, 0.4, 1.0, 0.3, 1.0, 0.0, 0.7), nrow=4,ncol=4,byrow=T) par(mar=c(0,0,0,0), oma=c(1,1,1,1)) split.screen(figs=mat) for (i in 1:4) { screen(n=i, new=F) plot(…) } close.screen(all.screens=T) Figures at arbitrary locations using split.screen Each row in matrix is the outline of a plot from 0 to 1 specified by: c(left, right, bottom, top) a different order from par or oma

18 mat <- matrix(c(0.0, 0.1, 0.9, 1.0, 0.0, 0.3, 0.7, 1.0, 0.1, 0.6, 0.4, 1.0, 0.3, 1.0, 0.0, 0.7), nrow=4,ncol=4,byrow=T) par(mar=c(0,0,0,0), oma=c(1,1,1,1)) split.screen(figs=mat) for (i in 1:4) { screen(n=i, new=F) plot(…) } close.screen(all.screens=T) Figures at arbitrary locations using split.screen 0.00.10.30.61.0 0.0 0.4 0.7 0.9 1.0

19 Branch et al. (2010) Nature 468:431-435

20

21 Dean’s Visualization Prize The class project comprises four figures: three on your own data, one on Porzio et al. (2011) The best portfolio of figures will be awarded the Dean’s Visualization Prize by Lisa Graumlich, dean of the College of the Environment Judges: Lisa Graumlich, Trevor Branch, Marilyn Ostergren, Liz Neeley The prize is attendance at full-day seminar by Edward Tufte (includes copies of his books, more details here http://www.edwardtufte.com/tufte/courses), or a selection of visualization and R books http://www.edwardtufte.com/tufte/courses

22 Porzio et al. (2011) Journal of Experimental Marine Biology and Ecology 400:278-287 Fig. 2. Kite diagram showing the distribution of the most abundant macroalgal species (N3% coverage) in 27 20×20 cm quadrats taken along a pH gradient from S1 (pH=8.1), S2 (pH=7.8) and S3 (pH=6.7). R=Rhodophyta, O=Ochrophyta, and C=Chlorophyta. Class project: Figure 1

23 Separate PowerPoint showing past class projects (not posted)

24 http://xkcd.com/688/ First attempt in R


Download ppt "Lecture 5 advanced multipanel plots Trevor A. Branch Beautiful graphics in R, FISH554 SAFS, University of Washington."

Similar presentations


Ads by Google