- Understanding the Grammar of Graphics
- Terminology for Interactive Graphics
- Interactive Graphic Examples
- Leading Platforms and Packages
- Future Research
Matthew Sigal (email@example.com)
The grammar of graphics takes us beyond a
The grammar is broken up into three components:
Assembly and Display are typically products of the software and hardware we use, so Wilkinson's primary emphasis is on Specification.
The first step is to extract data into variables.
We then can apply various algebraic techniques to the varset, which will define the structure (or frame) of our plot.
Three primary operators:
These are functions that are used to map varsets to dimensions (size, shape, and location).
Statistical operations can be employed to reduce the number of rows in the varset.
These functions create graph objects that can be represented by magnitudes in a space.
Our next step is to choose and apply a coordinates system.
|* Polygon||* Saturation||Voice|
|* Image||* Pattern|
(Wilksinson, 2005, p. 274)
In GPL, any statistical graphic can be expressed in terms of six statements:
DATA: y = "SepalWidth"
DATA: z = "species"
TRANS: x = x
TRANS: y = y
ELEMENT: point(position(x*y), color(z))
GUIDE: axis(dim(1), label("Sepal Length"))
GUIDE: axis(dim(2), label("Sepal Width"))
However, as most of these actions would be the default of a well-organized graphical system, only the ELEMENT statement is truly necessary.
General Principals for
geoms) that will be used to view the data
Components of a
Data: What we want to see!
Mapping: Defines the aesthetics of the graphic
Stat: Statistical transformations of the data (e.g., binning or averaging)
Geom: Geometric objects that are drawn to represent the data (simple or complex)
Position: Position adjustments for each geom (e.g., jitter, dodge, stack)
Scale: Controls mapping between data and aesthetics (variable or constant; colour/position)
Themes: Relatively new
ggplot2feature that allows for visual adjustments of a plot object
Coord: The coordinate system (provides axes and gridlines)
Facet: Allows us to break up the data into subsets
(Based upon Wickham, 2010)
Building the grouped scatterplot:
library(ggplot2) dat <- iris p1 <- ggplot(data = dat, aes(x = Sepal.Length, y = Sepal.Width, colour = Species)) + geom_point() + theme_bw() p1
Is this a perfect implementaion of the Grammar of Graphics?
ggplot2, we have to deal with:
Is this problematic?
ggplot2maintains the core beliefs of the system
+operator allows us to make changes to the general plot object
Dynamic, interactive visualizations...
to explore the data for themselves.
-Murray, 2013, p. 2
Overview first, zoom and filter, then details-on-demand.
-Shneiderman, 1996, p. 337
(the "Visual Information Seeking Mantra")
The most basic interactions allow the user to dynamically alter the parameters of a plot. This feature is already built into RStudio with the
For example, the following code allows users to dynamically alter:
manipulate(plot(iris$Sepal.Length, iris$Sepal.Width, xlim = c(x.min, x.max), type = type, axes = axes, ann = label), x.min = slider(0, 10, initial = 4), x.max = slider(0, 10, initial = 8), type = picker("points" = "p", "line" = "l", "none" = "n", initial = "points"), axes = checkbox(TRUE, "Draw Axes"), label = checkbox(TRUE, "Draw Axes Labels"))
While easy to use, unfortauntely,
manipulate has some draw-backs:
A more interesting example comes courtesy of Nacho Cabellero's
The goals of this package are to:
For example, here are the results of conducting multidimensional scaling on the
Interactivity can also be harnessed for pedagogical purposes. For instance, while teaching introductory statistics, we might want to visually demonstrate how skewness and kurtosis affect a distribution.
We can do this live via the
shiny package, which allows us to create a web application framework for R with "reactive bindings".
(This is an approximation based upon the sinh-arcsinh transformation; Jones & Pewsey, 2009)
R(if it should be done, there probably is a package)
Protovisfrom the Stanford Visualization Group
sigma.js: A library for interactive networks
Polymaps: US Unemployment 2009 Example
Processing and Processing.js:
Acinonyx, aka "iPlots eXtreme" - designed for large data (development limbo?)
animinthas a similar feature set to
clickme, but targeted specifically for
animation(self-explanatory; no interactivity)
GGobi(parallel coordinate plots; limited interactivity)
d3networkallows for the creation of D3-based force direction graphs in R
require(devtools); install_github("d3Network", "christophergandrud")
ggvisis still in development, but already has a plethora of examples.
ggplot2, geom is kind of abstract (e.g.,
ggvis, pure geoms are called "marks", and combined geoms and stats are referred to as "branches".
qplot()(or overloaded +)!
mark_symbol(props(size = input_slider(100, 1000))
# Installation: library(devtools) install_github(c("assertthat", "testthat")) install_github(c("httpuv", "shiny", "ggvis"), "rstudio")
rChartsleverages this somewhat by allow us to utilize JS libraries from within
ggplot2are both attempts at implementing Wilkinson's Grammar of Graphics in
ggsubplot), we can think of an interactive plot as a Grammar of Graphics pipeline that is continuously rendering.
Matthew J. Sigal, MA
Department of Psychology
262 Behavioural Science Building
York University, 4700 Keele St.
Toronto, ON, Canada M3J 1P3
(416) 736-2100 x66163
firstname.lastname@example.org / email@example.com
require(devtools); install_github("clickme", "nachocab")
require(devtools); install_github('rCharts', 'ramnathv')
Slides made with RStudio via Ramnath Vaidyanathan's
require(devtools); install_github('slidify', 'ramnathv');
require(devtools); install_github('slidifyLibraries', 'ramnathv')