A Grammar of Graphics
A Grammar of Graphics
A Grammar of Graphics
Past
If any number of
magnitudes are each
the same multiple of
the same number of
other magnitudes,
then the sum is that
multiple of the sum.
Euclid, ~300 BC
If any number of
magnitudes are each
the same multiple of
the same number of
other magnitudes,
then the sum is that
multiple of the sum.
Euclid, ~300 BC
m(x) = (mx)
Present
ggplot
Philosophy of ggplot
Examples from a recent paper
New methods facilitated by ggplot
Philosophy
Examples
30
h
t
i
w
d
e
t
a
e
r
c
y
l
r
l
u
a
i
o
t
i
t
n
I
n
o
i
t
a
l
corre
20
10
10
20
library(maps)
outlines <- as.data.frame(map("world",xlim=-c(113.8, 56.2),ylim=c(-21.2, 36.2)))
map <- c(
geom_path(aes(x = x, y = y), data = outlines, colour = alpha("grey20", 0.2)),
scale_x_continuous("", limits = c(-113.8, -56.2), breaks = c(-110, -85, -60)),
scale_y_continuous("", limits = c(-21.2, 36.2))
)
310
temperature
300
290
280
270
1995
1996
1997
1998
1999
2000
date
New methods
Supplemental statistical summaries
Iterating between graphics and models
Tables of plots
Inspired by ideas of Tukey (and others)
Exploratory graphics, not as pretty
Intro to data
Response of trees to gypsy moth attack
5 genotypes of tree: Dan-2, Sau-2, Sau-3,
Wau-1, Wau-2
2 treatments: NGM / GM
2 nutrient levels: low / high
5 reps
Measured: weight, N, tannin, salicylates
60
weight
50
30
20
40
10
Dan2
Sau2
Sau3
genotype
Wau1
Wau2
70
60
weight
50
30
High
20
10
Dan2
Sau2
nutr
Low
40
Sau3
genotype
Wau1
Wau2
70
60
weight
50
30
20
40
Low
10
Sau3
Dan2
Sau2
genotype
nutr
Wau2
Wau1
High
Comparing means
For inference, interested in comparing the
means of the groups
Supplemental summaries
Fro
m
70
60
weight
50
30
20
40
Low
10
Sau3
Dan2
Sau2
genotype
nutr
Wau2
Wau1
High
70
60
weight
50
30
20
40
Low
10
Sau3
Dan2
Sau2
genotype
nutr
Wau2
Wau1
High
Iterating graphics
and modelling
Clearly strong genotype effect. Is there a
nutr effect? Is there a nutr-genotype
interaction?
70
60
weight
50
30
20
40
Low
10
Sau3
Dan2
Sau2
genotype
nutr
Wau2
Wau1
High
20
10
nutr
weight2
10
20
Low
Sau3
Dan2
Sau2
genotype
Wau2
Wau1
High
10
weight3
nutr
Low
High
10
20
Sau3
Dan2
Sau2
genotype
Wau2
Wau1
Graphics Model
In the previous example, we used graphics
to iteratively build up a model - a la
stepwise regression!
Model Graphics
60
weight
20
40
bc
Sau3
Dan2
Sau2
Wau2
Wau1
genotype
Low
High
nutr
60
weight
nutr
Low
High
40
genotype
Tables of plots
Often interested in marginal, as well as
conditional, relationships
Dan2
Sau2
Sau3
Wau1
Wau2
4.5
4.0
3.0
2.5
High
3.5
trt
2.0
NGM
GM
4.5
4.0
3.0
2.5
2.0
Low
3.5
GM
NGM
GM
NGM
GM
NGM
trt
GM
NGM
GM
NGM
Dan2
Sau2
Sau3
Wau1
Wau2
(all)
4.5
4.0
3.0
2.5
2.0
High
3.5
4.5
trt
3.5
3.0
2.5
2.0
4.5
3.0
2.5
2.0
GM
NGM
GM
NGM
GM
NGM
GM
NGM
GM
NGM
GM
trt
NGM
(all)
3.5
4.0
Low
4.0
NGM
GM
Arranging plots
Facilitate comparisons of interest
Small differences need to be closer
Connections to model?
Summary
Need to move beyond canned statistical
Future
GGobi
ggplot2
rggobi
classifly
meifly
clusterfly
faceoff
geozoo
reshape
fda
hints
localmds
lvboxplot
scagnostics
DescribeDisplay
GGobi
ggplot2
fda
hints
localmds
lvboxplot
scagnostics
DescribeDisplay
rggobi
classifly
meifly
clusterfly
faceoff
geozoo
New methods
reshape
Foundations of
statistical graphics
Dissemination
and outreach
??
??
GGobi
rggobi
classifly
meifly
clusterfly
faceoff
geozoo
New methods
ggplot2
A grammar of
interactive
graphics
A grammar of
graphics for
categorical data
Foundations of
statistical graphics
reshape2
fda
hints
localmds
lvboxplot
scagnostics
DescribeDisplay
Dissemination
and outreach
Questions?