Chapter 2
Chapter 2
I N T R O D U C T I O N T O D ATA V I S U A L I Z AT I O N W I T H G G P L O T 2
Rick Scave a
Founder, Scave a Academy
Mapping onto the X and Y axes
ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width)) +
geom_point()
Type Variable
Color Species
Type Variable
Color Species
Type Variable
Color Species
Rick Scave a
Founder, Scave a Academy
Aesthetics? Attributes!
ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width)) +
geom_point(color = "red")
Type Property
Color "red"
Type Property
Size 4
Type Property
Shape 4
Rick Scave a
Founder, Scave a Academy
Positions
Adjustment for overlapping
identity
dodge
stack
ll
ji er
ji erdodge
nudge
scale_y_*()
scale_color_*()
Also scale_colour_*()
scale_fill_*()
scale_shape_*()
scale_linetype_*()
scale_size_*()
scale_y_*()
scale_color_discrete()
Alternatively, scale_colour_*()
scale_fill_*()
scale_shape_*()
scale_linetype_*()
scale_size_*()
Rick Scave a
Founder, Scave a Academy
Which aesthetics?
Use your creative know-how, and
Jacques Bertin
The Semiology of Graphics, 1967
William Cleveland
The Elements of Graphing Data, 1985
Primary: Never:
Always:
Visually appealing, beautiful plots
Accurate
Minimizes information loss