sbp dbp sex smoker
1 112 55 male former
2 144 84 male never
3 143 84 female never
4 110 62 female never
These slides are based on a similar set of slides presented by Danny Kaplan at the 2018 Computation and Visualization Consortium.
The were modified by Randall Pruim for use in courses at Calvin University.
A little history
Leland Wilkinson: The Grammar of Graphics
A little history
Hadley Wickham: A Layered Grammar of Graphics
In its original sense, in archaeology, a glyph is a carved symbol.
Heiroglyph | Mayan glyph |
---|---|
Features of a data glyph can encode the values of variables.
Each data glyph has a set of visual properties.
a visual property of a glyph such as position, size, shape, color, etc.
color
is determined by sex
color
is black
A mapping that translates data values into properties.
An indication for the human viewer of the scale. This allows the viewer to translate properties back into data values.
Scale: Data value \(\to\) property value
The conversion from SBP to position is a scale.
The conversion from Smoker (variable) to color (aesthetic) is a scale.
sbp
and sex
sex
Related terms: small multiples, subplots
Graphics are designed by the human expert (you!) in order to reveal information that’s latent in the data.
A good graphic is one that allows the viewer to make the intended comparison easily and accurately.
Remember: A good graphic is one that allows the viewer to make the intended comparisons easily and accurately.
Good graphics make it easy for people to perceive things that are similar and things that are different.
Need to know something about how people perceive.
Your choices depend on what information you want to reveal and convey.
Learn by reading graphics and determining which ways of arranging things are better or worse.
In roughly descending order of human ability to compare nearby objects:
Color can be the most difficult, because it is a 3-dimensional quantity.
color gradients — we’re better at this (makes color 2-d), but not if differences are subtle
discrete colors — must be carefully selected (and not too many)
not all people perceive colors equally well (color blindness, etc.)
What comparisons are easier to make now?
How else might we modify the plot? (For what purposes?)
Glyph-ready data has this form:
Glyph-ready data
sbp dbp sex smoker
1 112 55 male former
2 144 84 male never
3 143 84 female never
4 110 62 female never
Mapping of data to properties
sbp -> x
dbp -> y
smoker -> color
sex -> shape
Scales determine details of data -> aesthetic
translation
You can see the data used by ggplot layers using ggplot::layer_data()
.
Each layer may have its own data, glyphs, aesthetic mapping, etc.
sbp dbp sex smoker
1 112 55 male former
2 144 84 male never
3 143 84 female never
4 110 62 female never
Eye-training
Eye-training
Design
Eye-training
Design
Data wrangling
Eye-training
Design
Data wrangling
Graphics construction