11月10日台北天氣晴~
今天就來跟大家介紹如何改變背景顏色以及標題
這是我們昨日的圖~
ggplot(dat,aes(x = hp , y = mpg , label = car))+
geom_point(color = ifelse(dat$car == "","#330000","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,family = "A" )+
theme(axis.text.x=element_text(face="bold",size=9.2,angle=360,color="#333333"))+#x軸字型
theme(axis.text.y=element_text(face="bold",size=10,color="#333333"))+#y軸字型
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"))#Y軸標題
接下來我們改變theme() 中的 panel.background 及 plot.background
theme(panel.background=element_rect(fill='#cc9999', color="#000000",col = "red"))#圖的底色
theme(panel.background=element_rect(fill='#cc9999', color="#000000",col = "red"))#圖的底色
再來我們改變標題 , 並設定hjust = 0.5 置中
theme(plot.title=element_text(hjust = 0.5,face="bold",size=20,family = "A",color = "#990033"))#改標題字體位置
美化作業到這邊已經大有進展了!
明天再來看看可以加什麼!
End.