2015-02-24 24 views
1

蜱我已经得到了以下数据:如何扩展回归线和自定义轴中的R

vpri=seq(2,16,2) 
vfb = 1.87*vpri 

我要作出这样的外出从VFB = 1〜100在Y线性回归轴。 我已经尝试了一些东西,这个代码清盘:

ggplot(df, aes(x=vpri, y=vfb)) +geom_point(shape=1) + 
    xlim(0,60) + 
    stat_smooth(method="lm",fullrange = TRUE) +   
    scale_y_continuous(breaks=seq(0,100,5)) 

然而,事实是,我在arugments为xlim的60值是我唯一的猜测和检查后得到。

我想获得stat_smooth对象来对待y轴作为'fullrange'真正的判断,而不是x轴。此外,一旦我得到这一点,我会需要添加自定义的剔间距两轴(因为25 /划分太粗糙),但我知道R将抛出一个合适的,当我使用xlim(或ylim)作为事情驾驶stat_smooth,然后用scale_x_continuous要求它来处理蜱以后,或scale_y_continuous

回答

1

这做到了:

ggplot(df, aes(x=vpri, y=vfb)) +geom_point(shape=1) + # Use hollow circles 
    scale_x_continuous(limits=c(1,60),breaks=seq(0,60,5)) + 
    scale_y_continuous(breaks=seq(0,2*60,5)) + 
    stat_smooth(method="lm",fullrange = TRUE)