2013-07-05 66 views
0

在以下代碼中,fullrange = TRUE似乎被忽略。stat_smooth中忽略的fullrange = TRUE

任何想法有什麼不對?

df <- data.frame("x"=c(119,118,144,127,78.8,98.4,108,50,74,30.4, 
50,72,99,155,113,144,102,131,105,127,120,85,153,40.6,133), 
"y"=c(1.56,2.17,0.81,1.07,1.12,2.03,0.90,1.48,0.64, 
0.91,0.85,0.41,0.55,2.18,1.49,1.56,0.82,0.93,0.84,1.84, 
0.78,1.15,3.85,3.30,0.94))  

library(ggplot2) 
library(MASS)  

ggplot(df,aes(x=x,y=y))+geom_point(size=3,colour="black")+ 
stat_smooth(method="rlm",alpha=0.1,fullrange=TRUE,se=TRUE)+ 
theme_bw()+ 
theme(text = element_text(size=12),axis.title.y=element_text(size=12,face="bold"), 
axis.title.x=element_text(size=12,face="bold"), 
axis.line = element_line(colour = "darkgrey"), 
panel.border = element_blank())+coord_cartesian(xlim=c(0,200),ylim=c(0,4)) 

回答

1

您必須添加+ xlim(0,200)

+0

完全!謝謝... –

+0

這個答案也可能有所幫助:https://stackoverflow.com/a/35344520/7375944 – AJMA