11月9日台北變天了~
接續前日美化作業~
今天我們來調整 X軸、Y軸的標題!
#繪圖
ggplot(dat,aes(x = hp , y = mpg , label = car))+
geom_point(color = ifelse(dat$car == "","black","red") , size =ifelse(dat$car == "",1,3))+
labs(x = "馬力" , y = "油耗(英哩/加侖)",title = "馬力油耗圖")+
geom_label_repel(col = "darkgreen",size = 4.5)+
geom_text_repel(aes(label = dat$label),, alpha = 0.8,
nudge_x = -8,nudge_y = 0.4 )+
theme(axis.text.x=element_text(face="bold",size=9.2,angle=180,color="#333333"))+#x軸字型
theme(axis.text.y=element_text(face="bold",size=10,color="#333333"))#y軸字型
這是我們前日畫的圖
接著我們來改變座標軸標題
hjust = 0.5 -> 將標題置中
family = "A" -> 設定字體為A = 微軟正黑體
windowsFonts(A=windowsFont("微軟正黑體"))
theme(axis.title.x =element_text(hjust = 0.5,color="firebrick4",face="bold",size=15,family = "A"))+#X軸標題改成酒紅色
theme(axis.title.y =element_text(hjust = 0.5,color="firebrick4",angle=90,face="bold",size=15,family = "A"))
這樣就完成了座標軸的美化了!
接下來還有.....
End.