Introduction to Data Visualization with ggplot2
Rick Scavetta
Founder, Scavetta Academy
ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width)) +
geom_point()

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

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.

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().

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

| Aesthetic | Description |
|---|---|
| x | X axis position |
| y | Y axis position |
| Aesthetic | Description |
|---|---|
| x | X axis position |
| y | Y axis position |
| fill | Fill color |
| Aesthetic | Description |
|---|---|
| x | X axis position |
| y | Y axis position |
| fill | Fill color |
| color | Color of points, outlines of other geoms |
| 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 |
|---|---|
| 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 |
| 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 |
| 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 |
| 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