Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Grammar of Graphics

Similar presentations


Presentation on theme: "The Grammar of Graphics"— Presentation transcript:

1 The Grammar of Graphics
Using ggplot2 to create informative and beautiful graphics in R, easily

2 Introduction The painful process of creating graphs in SPSS
Creating complicated graphs in SPSS is possible, but very tedious. Total time; ~12 hours. Hard to change details Figure 19; Reforms (t0) by attitudes on Redistribution, within EVS waves. Footer text: to modify choose 'Insert' (or ‘View’ for Office 2003 or earlier) then 'Header and footer' 5/11/19

3 Plotting in R The basic R functions create functional plots, but are again quite limited. Creating trellis plots for complicated datasets with various graphical layers is time-consuming and requires programming experience. Lattice helps, and can be used to create anything you might desire… However, this will probably require writing custom panel functions, and can become difficult very quickly. Footer text: to modify choose 'Insert' (or ‘View’ for Office 2003 or earlier) then 'Header and footer' 5/11/19

4 The Grammar of Graphics
Leland Wilkinson’s approach Created by Leland Wilkinson, when working (ironically) for SPSS Ggplot2 is a (sometimes loose) implementation in R by Hadley Wickham Create plots not by choosing a chart, but by rules about the building blocks that make a graphic, written in the ‘grammar’ of graphics. Make graphics easier Grammar instead of preset plots facilitate innovative display options Footer text: to modify choose 'Insert' (or ‘View’ for Office 2003 or earlier) then 'Header and footer' 5/11/19

5 Example What is a pie chart?
How would you describe a pie chart to someone who has never seen one? A pie chart is a stacked barchart with polar coordinates With ggplot, the difference is “+ coord_polar(theta="y")” Footer text: to modify choose 'Insert' (or ‘View’ for Office 2003 or earlier) then 'Header and footer' 5/11/19

6 Examples in R Extremely easy to overlay different graphical elements and statistical transformations Very, very many different applications. (Try doing a google search) Themes can be created and applied to easily create plots with the same ‘look and feel’ (not in my presentation, homework?) Footer text: to modify choose 'Insert' (or ‘View’ for Office 2003 or earlier) then 'Header and footer' 5/11/19

7 helpful resources Ggplot2 documentation: Cookbook; Presentation by creator of ggplot2, examples and philosophy; Google, stack overflow, R mailing lists. Footer text: to modify choose 'Insert' (or ‘View’ for Office 2003 or earlier) then 'Header and footer' 5/11/19


Download ppt "The Grammar of Graphics"

Similar presentations


Ads by Google