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,資料框欄位,被「映射到」color,一個可見的美學屬性。

ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point()
| Type | Variable |
|---|---|
| Color | Species |
Species,資料框欄位,被「映射到」color,一個可見的美學屬性。
在 aes() 中設定映射。

ggplot(iris) +
geom_point(aes(x = Sepal.Length,
y = Sepal.Width,
col = Species))
僅在以下情況需要:

| Aesthetic | Description |
|---|---|
| x | X 軸位置 |
| y | Y 軸位置 |
| Aesthetic | Description |
|---|---|
| x | X 軸位置 |
| y | Y 軸位置 |
| fill | 填滿色 |
| Aesthetic | Description |
|---|---|
| x | X 軸位置 |
| y | Y 軸位置 |
| fill | 填滿色 |
| color | 點的顏色、其他幾何的外框色 |
| Aesthetic | Description |
|---|---|
| x | X 軸位置 |
| y | Y 軸位置 |
| fill | 填滿色 |
| color | 點的顏色、其他幾何的外框色 |
| size | 點的面積或半徑、線條粗細 |
| Aesthetic | Description |
|---|---|
| x | X 軸位置 |
| y | Y 軸位置 |
| fill | 填滿色 |
| color | 點的顏色、其他幾何的外框色 |
| size | 點的面積或半徑、線條粗細 |
| Aesthetic | Description |
|---|---|
| alpha | 透明度 |
| Aesthetic | Description |
|---|---|
| x | X 軸位置 |
| y | Y 軸位置 |
| fill | 填滿色 |
| color | 點的顏色、其他幾何的外框色 |
| size | 點的面積或半徑、線條粗細 |
| Aesthetic | Description |
|---|---|
| alpha | 透明度 |
| linetype | 虛線樣式 |
| Aesthetic | Description |
|---|---|
| x | X 軸位置 |
| y | Y 軸位置 |
| fill | 填滿色 |
| color | 點的顏色、其他幾何的外框色 |
| size | 點的面積或半徑、線條粗細 |
| Aesthetic | Description |
|---|---|
| alpha | 透明度 |
| linetype | 虛線樣式 |
| labels | 圖面或座標軸文字 |
| Aesthetic | Description |
|---|---|
| x | X 軸位置 |
| y | Y 軸位置 |
| fill | 填滿色 |
| color | 點的顏色、其他幾何的外框色 |
| size | 點的面積或半徑、線條粗細 |
| Aesthetic | Description |
|---|---|
| alpha | 透明度 |
| linetype | 虛線樣式 |
| labels | 圖面或座標軸文字 |
| shape | 形狀 |
ggplot2 資料視覺化入門