Visible aesthetics

Introduction to Data Visualization with ggplot2

Rick Scavetta

Founder, Scavetta Academy

Mapping onto the X and Y axes

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width)) + 
  geom_point()

Introduction to Data Visualization with ggplot2

Mapping onto color

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point()
Type Variable
Color Species

Introduction to Data Visualization with ggplot2

Mapping onto the color aesthetic

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point()
Type Variable
Color Species

Species, a dataframe column, is mapped onto color, a visible aesthetic.

Introduction to Data Visualization with ggplot2

Mapping onto the color aesthetic

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point()
Type Variable
Color Species

Species, a dataframe column, is mapped onto color, a visible aesthetic.

Map aesthetics in aes().

Introduction to Data Visualization with ggplot2

Mapping onto the color aesthetic in geom

ggplot(iris) + 
  geom_point(aes(x = Sepal.Length,
                 y = Sepal.Width,
                 col = Species))

Only necessary if:

  • All layers should not inherit the same aesthetics
  • Mixing different data sources

Introduction to Data Visualization with ggplot2

Typical visible aesthetics

Aesthetic Description
x X axis position
y Y axis position
Introduction to Data Visualization with ggplot2

Typical visible aesthetics

Aesthetic Description
x X axis position
y Y axis position
fill Fill color
Introduction to Data Visualization with ggplot2

Typical visible aesthetics

Aesthetic Description
x X axis position
y Y axis position
fill Fill color
color Color of points, outlines of other geoms
Introduction to Data Visualization with ggplot2

Typical visible aesthetics

Aesthetic Description
x X axis position
y Y axis position
fill Fill color
color Color of points, outlines of other geoms
size Area or radius of points, thickness of lines
Introduction to Data Visualization with ggplot2

Typical visible aesthetics

Aesthetic Description
x X axis position
y Y axis position
fill Fill color
color Color of points, outlines of other geoms
size Area or radius of points, thickness of lines
Aesthetic Description
alpha Transparency
Introduction to Data Visualization with ggplot2

Typical visible aesthetics

Aesthetic Description
x X axis position
y Y axis position
fill Fill color
color Color of points, outlines of other geoms
size Area or radius of points, thickness of lines
Aesthetic Description
alpha Transparency
linetype Line dash pattern
Introduction to Data Visualization with ggplot2

Typical visible aesthetics

Aesthetic Description
x X axis position
y Y axis position
fill Fill color
color Color of points, outlines of other geoms
size Area or radius of points, thickness of lines
Aesthetic Description
alpha Transparency
linetype Line dash pattern
labels Text on a plot or axes
Introduction to Data Visualization with ggplot2

Typical visible aesthetics

Aesthetic Description
x X axis position
y Y axis position
fill Fill color
color Color of points, outlines of other geoms
size Area or radius of points, thickness of lines
Aesthetic Description
alpha Transparency
linetype line dash pattern
labels Text on a plot or axes
shape Shape
Introduction to Data Visualization with ggplot2

Let's Practice

Introduction to Data Visualization with ggplot2

Preparing Video For Download...