An implementation of the grammar of graphics: ggplot
1. An implementation of the grammar
of graphics: ggplot*
An R package by Hadley Wickham
Presented by Mehran Karimzadeh
*By ggplot we mean ggplot2. ggplot is deprecated
2. The world without ggplot
R base graphics:
● Manual iteration for overplotting or facetting
● Manual selection of aesthetics
● Complex manual legends
● Hard to share or reuse
● ...
3. The grammar of graphics
Introduced by Leland Wilkinson in 1999
Essentially based on object oriented graphic
objects that inherit properties of each other
New graphic objects can be added to an
existing functional plotting object to alter
aesthetics, add features, etc.
4. Graphic objects
Each graphic object must inherit or be assigned with several
parameters:
● x/y-axis value
● aesthetics: colour/fill/etc.
Various graphical objects exist:
● geom: adding points/lines/bars/shapes/texts
● stat: control representation of data; often transformation
● scale: manual control of aesthetics
● coord: control coordinate system
● facet: Setting multipanel representation of data
● ...
5. Advantages of using ggplot
● No iteration for facetting or overplotting
● No need for specifying aesthetic features
● Can be reused efficiently for exploratory analysis
● Easy but extensive control over details of graphics
● Portable and dynamic
8. Syntax; Exploration
● To explore distribution/frequency/etc., each row of the
dataframe must have one entry of the measure you are
interested;
● Here, you can explore carat in relation to cut, color or clarity, but
you cannot compare distribution of carat versus depth or price.
● geoms: geom_histogram(), geom_density(), geom_boxplot(),
geom_violin(), etc.
9.
10. Most useful objects
Visuals: points, lines, bars, tiles, segments, polygon, text
Features: multi facetting, scaling, transforming, coordinate
systems, themes
15. Only with minimal functionality
Many features not yet available:
● Positioned bar plots
● boxplot
● facet_grid
● etc.
For contribution:
https://github.com/yhat/ggplot/blob/master/TODO.md