Talk Overview. grid Graphics and Programming. The Structure of R Graphics. Introduction to grid

Similar documents
Writing grid Code. Paul Murrell. December 14, 2009

Working with grid Viewports

R Graphics. Paul Murrell. The University of Auckland. R Graphics p.1/47

Working with grid Viewports

Modifying grid grobs

DATA VISUALIZATION WITH GGPLOT2. Grid Graphics

Display Lists in grid

Display Lists in grid

STA490HY1Y. Initial Examination of Data

R Lattice Graphics. Paul Murrell

The LDheatmap Package

A GUI-Builder Approach to grid Graphics

Package gridextra. September 9, 2017

Divide & Recombine for Large Complex Data (a.k.a. Big Data): Goals

grid Graphics Paul Murrell December 7, 2017

grid Graphics Paul Murrell October 6, 2005

Divide & Recombine (D&R) with Tessera: High Performance Computing for Data Analysis.

2 A Technical Overview of lattice

Package gridextra. July 2, 2014

Graphics in R. Jim Bentley. The following code creates a couple of sample data frames that we will use in our examples.

Package grimport. R topics documented: February 20, 2015

The gridsvg package. Paul Murrell. October 30, 2017

Package gridgraphics

Package grimport2. March 20, 2018

Graphical Programming: R Graphics from the Ground Up

Package RGraphics. March 11, 2014

Animation with the gridsvg package

Class #2 Lab: Basic CAD Skills & Standards. Basic AutoCAD Interface AutoCAD Skills AutoCAD Standards

Space. Pat Hanrahan. On Being the Right Size. Page 1

DC2 File Format. 1. Header line 2. Entity line 3. Point line 4. String line

Accessing Rhino Page Layouts

R: a nearly-lisp. Christophe Rhodes. April 6, Teclo Networks AG

How to use the ruler, grid, guides, and the Align panel

form are graphed in Cartesian coordinates, and are graphed in Cartesian coordinates.

Trellis Displays. Definition. Example. Trellising: Which plot is best? Historical Development. Technical Definition

To specify the dimensions of the drawing canvas use the size statement: ! size( 300, 400 );

INFS 2150 / 7150 Intro to Web Development / HTML Programming

CIND123 Module 6.2 Screen Capture

Package LDheatmap. R topics documented: August 24, Version Date

Correcting Grammar as You Type

Package YaleToolkit. February 15, 2013

Section A Solids Grade E

Quick Start: GeoDAS-LT with Single Beam Echo Sounder

Technology Assignment: Scatter Plots

User Manual Version 1.1 January 2015

CISC 1600, Lab 2.1: Processing

Unit 1, Lesson 1: Tiling the Plane

Objective: Construct perpendicular line segments on a rectangular grid.

INFS 2150 Introduction to Web Development

Picket Patterns. Overview

INFS 2150 Introduction to Web Development

Client-Side Web Technologies. CSS Part II

Lesson 14.1 Skills Practice

Help Guide Rev

Code Finix Label Designer V 1.0 User Guide

Module 5 Key Concepts

12 Interacting with Trellis Displays

CISC 1600 Lecture 3.1 Introduction to Processing

End-of-Module Assessment Task

Lesson 1 Parametric Modeling Fundamentals

Students construct nets of three dimensional objects using the measurements of a solid s edges.

SECOND GRADE Mathematic Standards for the Archdiocese of Detroit

Correcting Grammar as You Type. 1. Right-click the text marked with the blue, wavy underline. 2. Click the desired option on the shortcut menu.

Inserting a table plus all related tips on the table

Controlling the Drawing Display

Tutorial - FactoryPLAN

Chapter 2 Surfer Tutorial

CISC 1600, Lab 3.1: Processing

Excel Basics Tips & Techniques

S206E Lecture 3, 5/15/2017, Rhino 2D drawing an overview

Add and subtract within 20.

Chapter 2: From Graphics to Visualization

3. Prepare all your graphs, illustrations and text by cutting them to size. For straight lines use a guillotine.

Netscape Composer: Working with Tables

Publisher 2010 Foundation. Publisher 2010 Foundation Level SAMPLE

Security Management System Central Monitoring Station with Push Mode Connectivity

Install RStudio from - use the standard installation.

Adobe Photoshop Sh S.K. Sublania and Sh. Naresh Chand

Publisher 2016 Foundation SAMPLE

2.NS.2: Read and write whole numbers up to 1,000. Use words models, standard for whole numbers up to 1,000.

Microsoft Publisher 2013 Foundation. Publisher 2013 Foundation SAMPLE

L E S S O N 2 Background

Tips & Tricks Making Accessible PowerPoint Presentations

ENVI Tutorial: Introduction to ENVI

Publisher 2016 Foundation. North American Edition SAMPLE

Using MS Publisher. Launch MS Publisher: Start > All Programs > Microsoft Office > Publisher. Setting up Document Size and Orientation

CS 465 Program 4: Modeller

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Measuring Triangles. 1 cm 2. 1 cm. 1 cm

2nd GRADE-Math Year at a Glance

Adobe InDesign CS6 Tutorial

Features and Benefits

Adobe photoshop Using Masks for Illustration Effects

This project covers the following design concepts:

Guided Problem Solving

Road Map for Essential Studio 2010 Volume 1

Overview of Adobe Fireworks

InDesign Tools Overview

(Refer Slide Time: 00:02:00)

Layout Tutorial. Getting Started. Creating a Layout Template

Transcription:

Talk Overview grid Graphics and Programming Introduction to grid Important grid concepts Sketching with grid Annotating with grid Editing with grid Combining grid with traditional graphics Developing new graphics with grid Paul Murrell The University of Auckland user! 24, Vienna The Structure of R Graphics Introduction to grid Graphics Packages ellipse... lattice Graphics Systems graphics grid Graphics Engine Graphics Devices X11 postscript pdf...

What is grid? grid is an alternative to the traditional graphics system provided by the graphics package. grid provides low-level graphics functions for producing statistical graphics (at least). lattice provides high-level graphics functions using grid Why grid? grid began life purely as support for lattice The traditional system has some annoying constraints (e.g., text rotation in margins) The traditional system has some annoying inconsistencies (e.g., the meaning of col) As grid has developed, it has opened up opportunities to do some things that were not conceivable with the traditional system (e.g., interactive editing) Uses for grid As a drawing program Annotating lattice plots Editing lattice plots Tricky annotations of traditional plots (gridbase) Tricky arrangements of traditional plots (gridbase) Develop new graphics functions/components Important grid Concepts

Viewports A viewport is a rectangular region. > viewport(x =.5, y =.5, width =.5, height =.25, angle = 15) viewport[grid.vp.1] Pushing, Popping, Downing, and Upping The viewport() function only creates a description of a viewport. The viewport description must be pushed in order to create a region on the device. > pushviewport(viewport(x =.5, y =.5, width =.5, height =.25, + angle = 15)) viewport[grid.vp.8] A viewport can be removed from a device by popping it..5npc 1.5npc.25npc > popviewport() viewport[root] 1.5npc Pushing, Popping, Downing, and Upping Viewports can be nested within each other. > pushviewport(viewport(width =.8, height =.3, angle = 2, + name = "topvp")) viewport[topvp] > grid.rect(gp = gpar(fill = rgb(43/255, 14/255, 19/255))) > pushviewport(viewport(x = 1, width =.3, just = "right", name = "bottomvp")) viewport[bottomvp] > grid.rect(gp = gpar(fill = rgb(189/255, 21/255, 225/255))) Pushing, Popping, Downing, and Upping Instead of popping a viewport, it can be left in place, and we can navigate between viewports. > upviewport() viewport[root] > current.vptree() viewport[root]->(viewport[topvp]->(viewport[bottomvp])) ROOT topvp bottomvp

Pushing, Popping, Downing, and Upping Navigation amongst viewports makes use of viewport paths. > downviewport(vppath("topvp", "bottomvp")) viewport[bottomvp] > grid.text("back again!", gp = gpar(fontsize = 2)) Units and Coordinate Systems The unit() function associates values with coordinate systems. > unit(1, "npc") [1] 1npc > unit(1:3/4, "npc") [1].25npc.5npc.75npc back again! > unit(1:3/4, "npc")[2] [1].5npc > unit(1:3/4, "npc") + unit(1, "inches") [1].25npc+1inches.5npc+1inches.75npc+1inches > min(unit(.5, "npc"), unit(1, "inches")) [1] min(.5npc, 1inches) Units and Coordinate Systems Every viewport contains several coordinate systems. > pushviewport(viewport(xscale = c(, 1))) viewport[grid.vp.9] > pushviewport(viewport(x = unit(6, "native"), y = unit(.5, "npc"), + width = stringwidth("coordinates for everyone"), height = unit(3, + "lines"))) viewport[grid.vp.1] Layouts A layout divides a viewport into several rows and columns. You can specify different widths and heights of rows and columns. > grid.layout(3, 2, heights = unit(c(2,.5, 1), c("null", "cm", + "null")), respect = TRUE) 1 2null (1, 1) (1, 2) 2null.5 coordinates for everyone.5cm (2, 1) (2, 2).5cm (3, 1) (3, 2) 2 4 6 8 1

Layouts Other viewports can occupy one or more cells of the layout. > pushviewport(viewport(layout = grid.layout(3, 2, heights = unit(c(2, +.5, 1), c("null", "cm", "null")), respect = TRUE))) > pushviewport(viewport(layout.pos.row = 3)) grobs A grob is a description of a something to draw. > linesgrob(c(.25,.25,.75), c(.75,.25,.25)) [1] "lines[grid.grob.244]" > rectgrob() [1] "rect[grid.grob.245]" > textgrob("a label") [1] "text[grid.grob.246]" 2null 2null The grid.draw() function takes a grob and produces output on a device..5cm 1.5cm A gtree groups several grobs and allows them to be dealt with as a single object. 1 Drawing grobs For every *Grob() function there is a grid.*() function which creates a grob and draws it. grobs The following grobs and gtrees are currently available. > grid.lines(c(.25,.25,.75), c(.75,.25,.25)) > grid.rect() > grid.text("a label") A label movetogrob() linetogrob() linesgrob() segmentsgrob() arrowsgrob() polygongrob() circlegrob() rectgrob() textgrob() pointsgrob() xaxisgrob() yaxisgrob() grid.move.to() grid.line.to() grid.lines() grid.segments() grid.arrows() grid.polygon() grid.circle() grid.rect() grid.text() grid.points() grid.xaxis() grid.yaxis()

gpars A gpar is a collection of graphical parameter settings. > gpar(col = "red", lwd = 4, lty = "dashed") $col [1] "red" $lwd [1] 4 Recap viewports navigating the viewport tree units and coordinate systems layouts grobs gpars $lty [1] "dashed" attr(,"class") [1] "gpar" All viewports and grobs can have a gpar associated with them. The gpar settings in a viewport are inherited by grobs drawn in that viewport and by viewports pushed within the viewport. grid examples Sketching with grid

grid examples grid examples j j i h g a b c d g h i j d c b a i h g a b c d g h i j d c b Once upon a time... NA a grid examples grid examples 12 1. 3. 2. 4. 5. 6. 7. 1 8. 9. 1. 11. 12. 17. 13. 14. 15. 18. 16. Stopping Distance 8 6 4 19. 2. 21. 2 22. 23. 24. 25. 26. 5 1 15 2 25 Speed

lattice examples Barley Yield (bushels/acre) 4 8 12 Svansota No. 462 Manchuria No. 475 Velvet Peatland Glabron No. 457 Wisconsin No. 38 Trebi Grand Rapids 4 8 12 Duluth 4 8 12 University Farm 4 8 12 Morris 4 8 12 Crookston 4 8 12 Waseca 1932 1931 lattice examples Annotating and Editing with grid A lattice plot long lat

Viewing the viewports > current.vptree() viewport[root]->( viewport[grid.vp.52]->( viewport[grid.vp.55] viewport[grid.vp.57], viewport[grid.vp.59], viewport[grid.vp.51], viewport[grid.vp.511], viewport[grid.vp.512], viewport[grid.vp.513], viewport[grid.vp.515],... viewport[panel.1], viewport[panel.2], viewport[panel.3], viewport[panel.4], viewport[panel.5], viewport[panel.6], viewport[panel.7], viewport[panel.8])) Annotating the plot Navigate to panel 5 : > downviewport("panel.5") Add a text label in the bottom-left corner: > grid.text("add a\nlabel", x = unit(2, "mm"), y = unit(2, "mm"), + just = c("left", "bottom"), gp = gpar(col = "blue", lineheight = 1), + name = "ann.panel.5") Draw a rectangle enclosing a data range: > grid.rect(165, -22, 7, 12, default = "native", gp = gpar(col = "red"), + just = c("left", "bottom")) Annotating the plot long lat Add a label Editing the annotations > grid.edit("ann.panel.5", gp = gpar(col = "red")) long lat Add a label

Editing the annotations > grid.remove("ann.panel.5") long lat Combining grid and Traditional Graphics Annotating traditional plots with grid 2 4 6 8 1 one two three four five six seven eight nine ten Annotating traditional plots with grid 22 23 24 25 119.5 12. 12.5 121. 121.5 122. China Sea Wind Speed/Direction and Temperature latitude longitude

Arranging traditional plots with grid Developing New Graphics with grid y.2..2.4.6.8 1. 1.2.2..2.4.6.8 1. 1.2 x Reasons for using grid Greater flexibility in specifying placement of graphical output and arrangements of plots (units and layouts) More consistency and generality (viewports and gpars) Better access to coordinate systems and output (navigating the viewport tree and interacting with grobs) Modular graphics; locations and sizes are declarative and the actual output depends on the viewport context. Graphical functions and grobs can be reused and embedded within other output. grobs provide a programatically editable persistent representation of graphical output; there is an API for working with graphical descriptions (editgrob(), removegrob(), addgrob(), getgrob(), and save()). Embedding lattice output 1 1.8.8 yy xx.6 yy.6 xx.4.4 yy xx.2.2 yy xx.2.4.6.8 1.2.4.6.8 1 yy xx Female yy xx Male