iT邦幫忙

2025 iThome 鐵人賽

DAY 8
0

Claus O. Wilke 的《Fundamentals of Data Visualization》一書中提到:將資料對應於結果圖形的可量化特徵值上,就是資料視覺化。這些特徵可以被稱作 美學映射(aesthetics)視覺呈現。換個角度思考,這一點的重要性也反映在 ggplot2 的結構設計中 —— aes() 幾乎是每一張圖必不可少的元素。


三大核心元素:位置、形狀與顏色

在資料視覺化中,位置(Position)形狀(Shape)顏色(Color) 是最基本且關鍵的三種映射元素。這些元素透過 尺度(Scales) 來建立資料與視覺之間的橋樑。例如,連續型數據可以被映射成顏色的深淺變化,或點的座標位置;類別型數據則可能被映射成不同的顏色或形狀。


範例:氣溫的不同尺度呈現

假設我們想比較四個地區在一年 12 個月中的平均氣溫:不同的尺度組合,會帶給讀者完全不同的解讀角度。

  1. 溫度對應到 y 軸,月份對應到 x 軸:溫度屬於連續型變數,而月份屬於有序且離散的變數

https://ithelp.ithome.com.tw/upload/images/20250908/20177964O2niyj43rv.png

  1. 城市對應於 y 軸,月份對應於 x 軸:城市屬於無序且離散的變數,而月份屬於有序且離散的變數

https://ithelp.ithome.com.tw/upload/images/20250908/20177964wdjwIRfofh.png


比例墨水原理

在資料視覺化的設計中,有一個經典原則:比例墨水原理(the principle of proportional ink)。其核心思想是:當使用上色區域來表示數值時,該區域的面積應該與數值成正比

換句話說,視覺化結果所傳達的特徵必須與真實數據對應,否則可能導致誤導性的解讀。


範例:收入分布的視覺化

假設要比較美國不同地區的收入水準:

在這裡,長條高度要能忠實表達數據,避免造成誤解。

  1. 以非 0 為基礎的長條圖,來呈現不同城市收入中位數,結果視覺看起來檀香山市收入遠大於夏威夷郡

https://ithelp.ithome.com.tw/upload/images/20250908/20177964M4IYcn3NNb.png

  1. 以 0 為基礎的長條圖,來呈現不同城市收入中位數,結果是檀香山市收入僅略高於夏威夷郡,更為精準呈現數據真相

https://ithelp.ithome.com.tw/upload/images/20250908/20177964TdGtcoUeUW.png

  1. 當然,並非常長條圖皆要以 0 為基礎呈現,假設今日要呈現的是不同城市之間的收入差異,就並非以 0 為原點出發

https://ithelp.ithome.com.tw/upload/images/20250908/20177964RXjS8s5v1N.png


小結

今天我們從 aes() 出發,認識了資料與視覺化之間的連結。三大要素 —— 位置、形狀、顏色,透過尺度形成了數據與圖像的對應。同時,也強調了 比例墨水原理,提醒我們在設計圖表時,務必要讓視覺化的面積與真實數值保持一致,才能避免誤導觀眾。

資料視覺化不只是「美感」的呈現,更是「正確傳達」的責任。


🔎 English Abstract

This article examines the connection between data and visualization, inspired by Claus O. Wilke’s Fundamentals of Data Visualization. In ggplot2, the aes() function plays a crucial role, linking data variables to visual elements. Three core aesthetics—position, shape, and color—form the basis of visual encoding, with scales serving as the mechanism that maps data to graphical properties.

Using temperature data across different regions as an example, the article demonstrates how varying aesthetic mappings produce distinct interpretations. Assigning temperature to the y-axis versus using cities as categorical variables changes the way trends and comparisons are perceived.

The discussion highlights the principle of proportional ink, which states that the graphical area used to represent data values must remain proportional to the underlying numbers. When bar charts start from a non-zero baseline, differences in income may appear exaggerated, while using zero as a baseline ensures a more faithful representation. Nonetheless, when focusing on differences rather than absolute values, a non-zero baseline can still be appropriate.

Finally, the article illustrates how using bar height—rather than area—to represent income levels prevents misleading interpretations. The key takeaway is that data visualization must go beyond aesthetics to fulfill its responsibility of truthfully conveying information.


上一篇
調色與背景主題 ─ ggplot2 的顏色與主題應用
系列文
資料視覺化的探索之旅:從 ggplot2 技術到視覺化設計8
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言