10月30日台北天氣依舊棒~
既然連表名改好之後,那還有什麼可以再改進的地方呢?
這張圖雖然已經有用顏色區分各隊了,但....
顏色這麼多到底要怎麼看阿!!!!
所以我想乾脆我們就直接把所有隊名放在點上怎麼樣?
ggplot(A,aes(x = A$AVG , y = A$OBP )) + geom_point(aes(color = A$Team),size = 4)+
labs(x = "平均打擊率",y = "平均上壘率",title = "2012 MLB")+
xlim(c(0.233,0.275))+
ylim(c(0.294,0.338))+
geom_hline(yintercept=max(as.numeric(A$OBP)),linetype="dashed",colour="#0000ff",size = 1)+
geom_vline(xintercept=max(as.numeric(A$AVG)),linetype="dashed",colour="#0000ff",size = 1)+
geom_hline(yintercept=min(as.numeric(A$OBP)),linetype="dashed",colour="red",size = 1)+
geom_vline(xintercept=min(as.numeric(A$AVG)),linetype="dashed",colour="red",size = 1)+
scale_colour_discrete(name = "Team")
在我們原先的程式碼中,我們使用geom_text()
geom_text(label = A$Team , size = 4 , col = "darkgreen")
設定我們的標籤為隊名 , 字體大小為4 , 顏色為 darkgreen
如何~
這樣看起來是不是更好懂了呢~
End.