可見的美學屬性

ggplot2 資料視覺化入門

Rick Scavetta

Founder, Scavetta Academy

映射到 X 與 Y 軸

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

ggplot2 資料視覺化入門

映射到色彩

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

ggplot2 資料視覺化入門

映射到色彩美學屬性

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

Species,資料框欄位,被「映射到」color,一個可見的美學屬性。

ggplot2 資料視覺化入門

映射到色彩美學屬性

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

Species,資料框欄位,被「映射到」color,一個可見的美學屬性。

aes() 中設定映射。

ggplot2 資料視覺化入門

在 geom 中映射色彩美學屬性

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

僅在以下情況需要:

  • 並非所有圖層都要繼承相同的美學屬性
  • 混用不同的資料來源

ggplot2 資料視覺化入門

常見可見美學屬性

Aesthetic Description
x X 軸位置
y Y 軸位置
ggplot2 資料視覺化入門

常見可見美學屬性

Aesthetic Description
x X 軸位置
y Y 軸位置
fill 填滿色
ggplot2 資料視覺化入門

常見可見美學屬性

Aesthetic Description
x X 軸位置
y Y 軸位置
fill 填滿色
color 點的顏色、其他幾何的外框色
ggplot2 資料視覺化入門

常見可見美學屬性

Aesthetic Description
x X 軸位置
y Y 軸位置
fill 填滿色
color 點的顏色、其他幾何的外框色
size 點的面積或半徑、線條粗細
ggplot2 資料視覺化入門

常見可見美學屬性

Aesthetic Description
x X 軸位置
y Y 軸位置
fill 填滿色
color 點的顏色、其他幾何的外框色
size 點的面積或半徑、線條粗細
Aesthetic Description
alpha 透明度
ggplot2 資料視覺化入門

常見可見美學屬性

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

常見可見美學屬性

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

常見可見美學屬性

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

一起來練習吧!

ggplot2 資料視覺化入門

Preparing Video For Download...