Rich Pugh Andy Nicholls Head to Head: Lattice vs ggplot2 Rich Pugh

Slides:



Advertisements
Similar presentations
RESPONSIVE AND MOBILE DESIGN BY: CHRIS PASQUARETTE APRIL, 2013.
Advertisements

Writers Companion was designed as the ONE program you will need for the entire writing process: Brainstorm, Organize, Edit and Publish in one program.
Designing Reusable Frameworks for Test Automation
Chapter 3 – Web Design Tables & Page Layout
Introduction to Lattice Graphics Richard Pugh 4th December 2012.
Converting S-Plus Applications into R Andy Nicholls
1 Transforming GIS: Changing the Way you Map the World Introducing MapInfo Professional v12.5 June 2014.
Copywrite Digital Printers
Why ROOT?. ROOT ROOT: is an object_oriented frame work aimed at solving the data analysis challenges of high energy physics Object _oriented: by encapsulation,
Stat-JR: eBooks Richard Parker. Quick overview To recap… Stat-JR uses templates to perform specific functions on datasets, e.g.: – 1LevelMod fits 1-level.
Plotting with ggplot2: Part 1
Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall. Microsoft Office 2010 PowerPoint, Workshop 1 Communication with Presentations.
Reading Graphs and Charts are more attractive and easy to understand than tables enable the reader to ‘see’ patterns in the data are easy to use for comparisons.
Microsoft ® Office Word 2007 Training Bullets, Numbers, and Lists ICT Staff Development presents:
Using Lattice to Plot Grouped Data Richard Pugh 4 th December 2012.
Eclipse[10] MIPSinEclipse. Overview Goal: To provide a friendly development environment for CS students programming in MIPS (particularly CS33 at UCLA),
R for Research Data Analysis using R Day2: Advanced R Baburao Kamble University of Nebraska-Lincoln.
Content Management Systems Why to use. And, if you’re going to use one, which one???
Radial Basis Function (RBF) Networks
XP New Perspectives on Microsoft Access 2002 Tutorial 71 Microsoft Access 2002 Tutorial 7 – Integrating Access With the Web and With Other Programs.
Exploratory Data Analysis. Computing Science, University of Aberdeen2 Introduction Applying data mining (InfoVis as well) techniques requires gaining.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
Baburao Kamble (Ph.D) University of Nebraska-Lincoln
CPSC 203 Introduction to Computers T59 & T64 By Jie (Jeff) Gao.
XP New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
Web Technologies Website Development Trade & Industrial Education
 Overview of SPSS  Interface  Getting Started  Managing Data  Descriptive Statistics  Basic Analysis  Additional Resources.
A Jumpstart to WPF by Kevin Grossnicklaus ArchitectNow.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
Ranjeet Department of Physics & Astrophysics University of Delhi Working with Origin.
Lecture 3 + Seminar 3 A workshop on graphing using ggplot2.
Drag and Drop Display and Builder. Timofei B. Bolshakov, Andrey D. Petrov FermiLab.
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
Introduction to ArcGIS for Environmental Scientists Module 1 – Data Visualization Chapter 3 – Symbology and Labeling.
Selected Topics in Software Engineering - Distributed Software Development.
Introduction to MATLAB Damon Tomlin February 22, 2008 Lecture 3: Data Visualization & User Interfaces.
1 (21) EZinfo Introduction. 2 (21) EZinfo  A Software that makes data analysis easy  Reveals patterns, trends, groups, outliers and complex relationships.
Advanced Stata Workshop FHSS Research Support Center.
_______________________________________________________________CMAQ Libraries and Utilities ___________________________________________________Community.
Orchard CMS Front-End Styling Rebecca Pleshaw Cloud Construct, LLC June 20, :00pm – 8:00pm Microsoft N.E.R.D. Building
240-Current Research Easily Extensible Systems, Octave, Input Formats, SOA.
Return to Outline Copyright © 2011 by Maribeth H. Price 3-1 Labeling and annotation.
Notes Graphs. Types of graphs A graph is just a picture of an amount of something. Like size of buildings since 1900.
McGraw-Hill Career Education© 2008 by the McGraw-Hill Companies, Inc. All Rights Reserved. Office Excel 2007 Lab 2 Charting Worksheet Data.
Sky Boxes and Vector Math 2 Course Information CVG: Programming 4 My Name: Mark Walsh Website:
Ggplot2 A cool way for creating plots in R Maria Novosolov.
Evolution of Graphic Organizers within an Academic Wiki Andrew Moshirnia University of Kansas.
| nectar.org.au NECTAR TRAINING Module 4 From PC To Cloud or HPC.
CAG - The influence of CAG Systems on Industry and Society Graphic Communication Knowledge & Understanding.
Adxstudio Portals Training
CPSC 203 Introduction to Computers T97 By Jie (Jeff) Gao.
Guided Lesson.  In this lesson, you will learn how to modify the line and paragraph spacing in various ways.
An Introduction to JQuery Mobile By Trevor Seeney.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
1 G4UIRoot Isidro González ALICE ROOT /10/2002.
Presenting Multivariate Data Harry R. Erwin, PhD School of Computing and Technology University of Sunderland.
Setting Defaults in Microsoft Word for Accessibility
Using R Graphs in R.
Overview Power Quality Dashboard Fred Elmendorf August 2014.
By Dr. Madhukar H. Dalvi Nagindas Khandwala college
Lecture 25.
ggplot2 Merrill Rudd TAs: Brooke Davis and Megsie Siple
Tutorial 4: Enhancing a Workbook with Charts and Graphs
Using Cornell Notes in the Math classroom.
Introduction to R Studio
Webinar – New KStutor Overview 25th October 2013
(Mohammed Sami) Ashhab
INTRODUCTION TO SGPLOT Zahir Raihan OVERVIEW  ODS Graphics  SGPLOT overview  Plot Content  High value plot statements  High value plot options 
The poster title goes here and here
The Grammar of Graphics
Presentation transcript:

Rich Pugh Andy Nicholls Head to Head: Lattice vs ggplot2 Rich Pugh Andy Nicholls

Rich Pugh Andy Nicholls Head to Head: ggplot2 vs Lattice Rich Pugh Andy Nicholls

Rich Pugh Andy Nicholls Why are we here? Mango have traditionally used lattice for our software products, training, etc ggplot2 is increasingly popular in the community Rich likes Lattice Andy likes ggplot2

Rich Pugh Andy Nicholls Aim To present R graphics users with enough information to make an informed choice as to which graphics package best meets their needs

Rich Pugh Andy Nicholls Agenda Approach and Data Introduction to Lattice Introduction to ggplot2 The Challenge! Why and Why Not Lattice Why and Why Not ggplot2 Conclusions

Rich Pugh Andy Nicholls Approach Demonstrate the common package features Panelling Grouping Legends Styling Advanced control Create the same graphic in the two technologies and compare the code Discuss

Rich Pugh Andy Nicholls The Data Something sector independent London Tube Performance Data from the TFL website Excess Travel Hours by Line network-performance-data

Rich Pugh Andy Nicholls The Data

Rich Pugh Andy Nicholls Data Tweaks These data have been modified from the original source Further data transformations were required for ggplot2, more on that later…

Rich Pugh Andy Nicholls Lattice

Rich Pugh Andy Nicholls Overview of Lattice Graphics One of the graphic systems of R An implementation of the S+ Trellis Graphics Written by Deepayan Sarkar, Fred Hutchinson Cancer Research Center

Rich Pugh Andy Nicholls List of Lattice Graphic Functions FunctionDescriptionGraph Type xyplot Scatter plotBivariate histogram Univariate histogramUnivariate densityplot Univariate density line plotUnivariate barchart Bar chartUnivariate bwplot Box and whisker plotBivariate qq Normal QQ plotUnivariate dotplot Label dot plotBivariate cloud 3D scatter plot3D wireframe 3D surface plot3D splom Scatter matrix plotData Frame parallel Multivariate parallel plotData Frame

Rich Pugh Andy Nicholls Key Function Arguments ArgumentDescription x Plot definition, typically as a formula data The data frame used for the graphic subset Any subsets to be applied to the data panel Function used to draw data in each panel groups Grouping variable for the plot Type of graphFormulaY axisX axisZ axis Univariate~ YY-- BivariateY ~ XYX- 3DZ ~ X*YYXZ Data Frame~ DataData--

Rich Pugh Andy Nicholls Building A Graphic

Rich Pugh Andy Nicholls A Simple Scatter Plot

Rich Pugh Andy Nicholls Panelling

Rich Pugh Andy Nicholls Grouping

Rich Pugh Andy Nicholls Styling

Rich Pugh Andy Nicholls Manipulating Plot Structure You can control the exact plot created at 2 levels: Panel: Plot for each plot panel Panel.groups: Plot for each group of data Each input takes a function panel.groups is called from within your panel function

Rich Pugh Andy Nicholls Panel Functions

Rich Pugh Andy Nicholls The panel.groups Function

Rich Pugh Andy Nicholls Quick Summary of Lattice Very effective for grouping and panelling Big plus for fine level group control However: Default styling could be better Can get a little fiddly for bespoke graphics

Rich Pugh Andy Nicholls ggplot2

Rich Pugh Andy Nicholls GGplot2 Graphics Graphical package created by Hadley Wickham Implements the ideas found in the book The Grammar of Graphics

Rich Pugh Andy Nicholls ggplot2 Graphics Like lattice: Plots are stored in objects Graphs may be controlled with a no $ syntax It is easy to create panelled graphics Plots built by layering features Heavy use of aesthetics and facets (as per Wilkinsons book)

Rich Pugh Andy Nicholls Using ggplot2 Two primary ways of creating a plot: Create a quick plot using qplot Create plot at a more granular level using ggplot We can use a mixture of the above approaches

Rich Pugh Andy Nicholls Using ggplot2 We then modify this plot by adding layers: New data Scales mapping aesthetics to data A geometric object A statistical transformation Position adjustments within the plot area Faceting (panelling) The coordinate systems itself

Rich Pugh Andy Nicholls Building A Graphic

Rich Pugh Andy Nicholls A Simple Scatter Plot

Rich Pugh Andy Nicholls Panelling

Rich Pugh Andy Nicholls Panelling (Alternative)

Rich Pugh Andy Nicholls Grouping

Rich Pugh Andy Nicholls Styling Styling appears in many places in ggplot2 The graphics shown so far have already been styled to some degree In-built themes control general page styling: Plot styling is controlled by scale layers…

Rich Pugh Andy Nicholls Styling

Rich Pugh Andy Nicholls Customisation

Rich Pugh Andy Nicholls Quick Summary of ggplot2 Very effective for grouping and panelling Styling is good However: Users need tricks for fine level control

Rich Pugh Andy Nicholls The Challenge

Rich Pugh Andy Nicholls The Challenge

Rich Pugh Andy Nicholls Traditional Graphics Code

Rich Pugh Andy Nicholls The Challenge: Lattice

Rich Pugh Andy Nicholls The Challenge: Lattice

Rich Pugh Andy Nicholls The Challenge: ggplot2

Rich Pugh Andy Nicholls Comparison

Rich Pugh Andy Nicholls Why Lattice Intuitive structure for controlled data at a group / subgroup level Achieve simple panelled graphics very quickly Well documented Extensions available (latticeExtra, nlme) A lot faster than ggplot2!

Rich Pugh Andy Nicholls Why Not Lattice? Default options can be frustrating Default styling doesnt look great Making good use of the panel / panel.groups structure needs lots of function knowledge Some tricks needed to do more than 2 levels of nested grouping

Rich Pugh Andy Nicholls Frustration #1: Panel Headers

Rich Pugh Andy Nicholls Frustration #2: Panel Order

Rich Pugh Andy Nicholls Frustration #2: Panel Order

Rich Pugh Andy Nicholls Frustration #3: Using styles

Rich Pugh Andy Nicholls Why ggplot2? All the panelling advantages of lattice plus … Its pretty Its quick (to type) Styling is handled for you

Rich Pugh Andy Nicholls Why ggplot2?

Rich Pugh Andy Nicholls Why Not ggplot2? Steep learning curve

Rich Pugh Andy Nicholls Steep Learning Curve

Rich Pugh Andy Nicholls Why Not ggplot2? Steep learning curve Help files are difficult to navigate Graphics are slower to render Limitations of framework Can feel hacky for non-standard graphics No 3D graphics Complex examples may require grid knowledge

Rich Pugh Andy Nicholls Page Layout using grid

Rich Pugh Andy Nicholls Page Layout using grid

Rich Pugh Andy Nicholls Conclusions Both save huge amounts of time vs graphics ggplot2 styling is nice and easier to control Lattice is more flexible and is quicker to render Audience Vote!