2013年11月1日 星期五

mac 中文字型 plot

主題: ggplot2 中文字型處理

更新日期: 2026.08.28

theme(
    plot.title = element_text(hjust = 0.5, family = "PingFang TC") # for macOS 中文字型
)

主題: macOS 中文字型處理

更新日期: 2023.11.01

Mac 作業系統繪製  R 圖形結果中,會有中文字型無法顯示,即只會顯示方框結果。
解決方式:

1. 先利用 字體簿 檢查Mac 可使用之中文字型,本例採用楷體,即 "STKaiti"。

2. 輸入 par(family="STKaiti") 即可指定繪圖採用之字型。繪製結果如下,標題等已可以完整顯示中文:


# title: chinese font plot setting in Mac
# date: 2013.11.2
par(family="STKaiti")
sales <- c(11,13,16,10,19)
plot(sales, main="RWEPA公司102年1月至6月銷售統計圖", 
     type="b", xlab="月份", ylab="銷售金額(萬元)")
# end

沒有留言:

張貼留言