每年產量<-一般廢棄物產生量|>
group_by(年)|>
summarise(
每年產生量=sum(產生量)
)
ggplot(每年產量,
mapping = aes(x=年,y=每年產生量))+
geom_bar(stat="identity",fill="#6699cc")+
labs(title = "全臺每年垃圾產量",
y="產生量(公噸)")台灣各縣市垃圾處理效率分析-垃圾產生量與掩埋和焚化量
數據科學專題期中報告
圖表製作
全台廢棄物產生
各縣市垃圾產生量
ggplot(
data = 一般廢棄物產生量,
mapping = aes(x = 年, y = 產生量, color=縣市)
)+
geom_point()+
geom_line(size = 1)+
facet_wrap(~縣市分類)+
geom_label_repel(
aes(label = 縣市),
data = 一般廢棄物產生量 |>
group_by(縣市) |>
slice_tail(n = 1),
show.legend = FALSE
) +
labs(
title = "一般廢棄物產生量趨勢-比例調整前",
y="產生量(公噸)"
) +
theme(legend.position = "none")ggplot(
data = 一般廢棄物產生量,
mapping = aes(x = 年, y = 產生量, color = 縣市)
) +
geom_point() +
geom_line(size = 1) +
facet_wrap(~縣市分類, scales = "free") +
geom_label_repel(
aes(label = 縣市),
data = 一般廢棄物產生量 |>
group_by(縣市) |>
slice_tail(n = 1),
show.legend = FALSE
) +
labs(
title = "一般廢棄物產生量趨勢-比例調整後",
y="產生量(公噸)"
) +
theme(legend.position = "none")各縣市掩埋場數量和容量比較
ggplot(
data = 掩埋場容量,
mapping = aes(x = 數量, y = 容量)
) +
geom_point(size=2) +
geom_label_repel(data = 掩埋場容量|>
filter(容量<=2000000),
aes(label = 縣市),
size = 3,
nudge_y = 2,
max.overlaps = Inf
) +
geom_point(data = 掩埋場容量|>
filter(容量>=2000000),
size=2,col="red") +
geom_label_repel(data = 掩埋場容量|>
filter(容量>=2000000),
aes(label = 縣市),
size = 3,
nudge_y = 2,
max.overlaps = Inf,col="red"
) +
geom_point(data = 掩埋場容量|>
filter(容量==0),
size=2,col="blue") +
theme(legend.position = "none")+
labs(title="各縣市掩埋場容量",
x="掩埋場數量",
y="掩埋場容量(立方公尺)")ggplot(
data = 焚化爐設計處理容量,
mapping = aes(x=數量, y=日處理量,col=數量)
)+
geom_point(size=3)+
geom_label_repel(
aes(label = 縣市),
size = 3,
nudge_y = 0.5,
max.overlaps = Inf,
)+
scale_color_gradientn(
colors = c("black", "#6B8E23","#4169E1", "#DAA520", "red") # 指定多個漸層顏色
) +
theme(legend.position = "none")+
labs(
title = "各縣市焚化爐設計容量",
x="焚化爐數量",
y="日處理量(公噸)"
)各縣市近20年平均廢棄物產生量
各縣市平均產生<-一般廢棄物產生量|>
group_by(縣市)|>
summarise(
各縣市平均產生= mean(產生量, na.rm =TRUE)
)|>
arrange(desc(各縣市平均產生))
ggplot(各縣市平均產生,
mapping = aes(fct_reorder(縣市, 各縣市平均產生),y = 各縣市平均產生))+
geom_bar(stat="identity",fill="#6699cc")+
labs(
title = "各縣市平均廢棄物產生量",
x = "縣市",
y = "平均產生量(公噸)"
)+
theme_minimal() +
coord_flip()未設有焚化爐的地區
未設有焚化爐的縣市<-焚化量|>
filter(
縣市%in%c("新竹縣","南投縣","雲林縣","花蓮縣","澎湖縣","金門縣","連江縣")
)
ggplot(未設有焚化爐的縣市,
mapping = aes(x=年,y=量))+
geom_line()+
geom_vline(xintercept = 94, color = "#009999", linetype = "dashed") +
facet_wrap(~縣市)+
labs(title = "未設有焚化爐的縣的焚化量",
y="焚化量(公噸)"
)掩埋/焚化與處理量之比較
掩埋<-衛生掩埋量|>
mutate(量_千=量/1000)
焚化<-焚化量|>
mutate(量_千=量/1000)
處理<-處理量|>
mutate(量_千=量/1000)
ggplot()+
geom_area(data=掩埋,aes(x=年,y=量_千),fill = "red", alpha = 0.5)+
geom_area(data=焚化,aes(x=年,y=量_千), fill = "purple", alpha = 0.5)+
geom_area(data=處理,aes(x=年,y=量_千), fill = "lightblue", alpha = 0.5)+
facet_wrap(~縣市, scales = "free_y")+
labs(title = "掩埋/焚化與處理量之比較",
caption = "紅色=衛生掩埋量;紫色=焚化量;藍色=處理量",
x = "年",
y = "處理(一千公噸) / 掩埋(一千立方公尺) / 焚化量(一千公噸)"
)近五年處理量及產生量比較
log產生及處理<- 產生及處理|>
mutate(產生量_log=log(產生量),
處理量_log=log(處理量))
ggplot(
data=log產生及處理,
mapping = aes(x=產生量_log,y=處理量_log,color=縣市)
) +
geom_abline(intercept = 0, slope = 1, color = "grey", linetype = "dashed")+
geom_point(
data =log產生及處理|>filter(產生量_log>處理量_log),size=3
)+
geom_point(
data =log產生及處理|>filter(產生量_log<處理量_log), color="black",size=4
)+
geom_point(
data =log產生及處理|>filter(產生量_log<處理量_log),size=3
)+
facet_wrap(~年)+
geom_label_repel(data =log產生及處理|>filter(產生量_log<處理量_log),
aes(label = 縣市),
size = 3,
nudge_y = 2,
max.overlaps = Inf
) +
labs(
title = "近五年處理量及產生量比較",
x="產生量_log(公噸)",
y="處理量_log(公噸)"
)一般廢棄物及焚化爐設計容量/掩埋量比較
ggplot(mapping = aes(x=年, y=產生量 / 設計容量)) +
geom_line(data = 一般廢棄物產生量 , aes(x = 年, y=產生量))+
geom_line(data=焚化爐總處理, aes(x = 年, y=總處理), col="red")+
geom_line(data=衛生掩埋量,aes(x = 年, y=量), col="blue")+
facet_wrap(~縣市, scales = "free")+
labs(title ="一般廢棄物及焚化爐設計容量/掩埋量比較",
y="產生量(公噸) / 掩埋容量(立方公尺) / 焚化量(公噸)")