2012-08-12 42 views
6

如何避免繪製以下數據時出現的繪圖區域的灰色陰影?ggplot中的geom_smooth導致繪圖背景的一部分改變顏色

df <-data.frame(x = c(0,0.2,0.5), y = c(0.6,0.7,0.9)) 

p <-ggplot(df, aes(x, y, ymin=0, ymax=1, xmin=0, xmax=1)) 

p <- p + geom_point(alpha=2/10, shape=21, 
       fill="blue", colour="black", size=5) 

p 

enter image description here

所以細直到這一點但然後加入用geom_smooth一個直線方程引起背景的一部分,成爲灰色。

p <- p + geom_smooth(method="lm", se=FALSE, formula=y~x, colour="black") 
p 

enter image description here

如何避免這種情況有什麼建議?謝謝。

回答

7

添加fill=NA到您的通話geom_smooth

p + geom_smooth(method="lm", se=FALSE, formula=y~x,colour="black",fill=NA) 
+0

感謝您的快速回復! – Elizabeth 2012-08-12 14:30:58