Skip to content

Instantly share code, notes, and snippets.

@mutolisp
Last active May 1, 2023 15:38
Show Gist options
  • Save mutolisp/3cc9c337c271fbfd12ec6e15a05f8d23 to your computer and use it in GitHub Desktop.
Save mutolisp/3cc9c337c271fbfd12ec6e15a05f8d23 to your computer and use it in GitHub Desktop.
繪製生態氣候圖
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Prec. 53 84 178 158 137 114 132 165 183 218 198 84
Max.t. 31 31 31 31 31 30 29 28 29 30 29 30
Min.t. 21 21 21 21 21 21 19 20 20 20 20 20
Ab.m.t. 17 18 17 18 18 18 17 17 17 18 18 16
# 載入 library
library(climatol)
library(Cairo)
# 設定工作目錄
setwd('/Users/psilotum/Documents/Dropbox/Courses/植群生態學/climatic_diagram/')
# 如果你是使用 Windows ,請用 C:\\ 這樣的路徑,例如 C:\\tmp 之類的
setwd('C:\\tmp')
# 設定字型,這裡使用 Noto Sans T Chinese (系統需要安裝這個字型)
CairoFonts(regular = "Noto Sans T Chinese:style=Light", bold = "Noto Sans T Chinese:style=Regular")
par(family='Noto Sans T Chinese')
# custom function to draw climatic diagrams
exportEcoDiag <- function(climfile, station_name, filename, elevation, data_period) {
climdata <- read.csv(climfile, row.names = 1)
# 設定輸出圖檔為 png
Cairo(1600, 1600, file=filename, type="png", bg="white", dpi=300)
diagwl(climdata, est=station_name,
alt=elevation, per=data_period)
dev.off()
}
# Zonobiome I
exportEcoDiag('Congo_Kisangami.csv', 'Kisangami (Congo)', 'ZB1-Kisangami.png',
'447', '2010')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment