精選好文
- 數據如何說故事?Adobe 專家親授的資料視覺化與行銷決策指南
- 超越圖表美學:數據視覺化在行銷策略中的敘事與決策力量
- 數據背後的說故事力量:如何用「行銷數據視覺化」驅動策略決策
- 告別圖表垃圾: 運用「訊雜比」與「資料墨水比」改造你的高溝通效率行銷圖表
- 跨部門數據協作:用數據視覺化消弭行銷與業務的溝通盲點
- 數據視覺化的色彩密碼:別把圖表當畫布,行銷人的色彩溝通學
進階選讀
- 選擇色譜(Colormaps) – Matplotlib
- The 9 Most Critical Plots Every Data Scientist Must Master
- Python 視覺化工具地圖 PyViz: 整理出完整生態系,讓你能快速找到最適合的工具,把複雜的數據「畫」成容易理解的洞察
設定中文字檔(以防止繪圖時產生豆腐字)
將這段程式碼放在繪圖之前(建議在notebook一開始就先執行將顯示中文環境設定好)
# 安裝思源黑體(Noto Sans CJK),畫中文圖表用得到
try:
!apt-get -qq -y install fonts-noto-cjk > /dev/null 2>&1
import matplotlib
import matplotlib.font_manager as fm
fm.fontManager.__init__() # 讓 matplotlib 重新掃描字型
matplotlib.rcParams["font.family"] = "Noto Sans CJK JP" # 思源黑體含繁中字
print("中文字型安裝設定完成")
except Exception as e:
print(f"🚨 中文安裝設定失敗:{e}")
或是下面程式碼也可以(不同中文字型與安裝方式)
"""
設定要使用的中文字型
"""
import matplotlib.font_manager as fm
import matplotlib.pyplot as plt
# 取得中文字型檔並設定字型管理員(fontManager),以利 Matplotlib 正常顯示圖表中的中文
!mkdir -p /usr/share/fonts/truetype/chocolateclassicalsans/
!wget -O /usr/share/fonts/truetype/chocolateclassicalsans/ChocolateClassicalSans-Regular.ttf "https://github.com/google/fonts/raw/main/ofl/chocolateclassicalsans/ChocolateClassicalSans-Regular.ttf"
try:
my_font = '/usr/share/fonts/truetype/chocolateclassicalsans/ChocolateClassicalSans-Regular.ttf'
fm.fontManager.addfont(my_font) # Add my_font to the font manager
font_prop = fm.FontProperties(fname=my_font)
plt.rcParams['font.family'] = font_prop.get_name()
print("✅ 中文字型設定完成!")
except Exception as e:
print(f"🚨 中文字型設定失敗:{e}")