[R] How to show the second abline ?

Jim Lemon jim at bitwrit.com.au
Sat Nov 9 00:01:26 CET 2013


On 11/09/2013 03:04 AM, Domokos Péter wrote:
> Hi,
>
> I have the next script in R:
>
> x=c(8.0,17.5,23.5,32.0,38.5,48.5,58.5,68.5)
> y=c(267,246,290,294,302,301,301,298)
>
> gap.plot(x,y,ylim=c(8,310),pch=8,cex=0.5,
> xlab=c('Time'),ylab=c('uS'),
> gap=c(30,240),gap.axis='y',
> ytics=c(10,20,30,270,280,290,300))
> abline(h=31,col='white',lwd=20)
> axis.break(axis=2,31)
> axis.break(axis=4,31)
>
> abline(coef(lm(x~y)),col=1)#Why don't show this???
>
Hi Peter,
Perhaps because both of these numbers:

coef(lm(x~y))
  (Intercept)            y
-176.5047160    0.7425131

are off the scale of your plot. Do you really want:

lmcoef<-coef(lm(y~x))
abline(lmcoef[1]-210,lmcoef[2],col=1)

Jim



More information about the R-help mailing list