[R] abline is not plotting

John Kane jrkrideau at inbox.com
Fri Oct 4 17:35:59 CEST 2013


Well you logged the x and y values before plotting but did not log the lm(). I think this means you have plotted abline() off the scale.  

I'm not sure how to fix it though.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: hans_hans74 at gmx.de
> Sent: Fri, 4 Oct 2013 07:16:49 -0700 (PDT)
> To: r-help at r-project.org
> Subject: [R] abline is not plotting
> 
> Hello there,
> 
> I have some data I want to plot together with a best-fit line. (see MWE
> below)
> The points from the first plot does appear as expected, but the abline
> does
> not appear, no matter what I change. I removed the log parameter before,
> but
> the abline is a very steep line around the origin. I really want to keep
> the
> logarithmic scale, plus a working abline.
> 
> Can someone help me with that? What am I doing wrong?
> 
> Thanks in advance,
> Hans
> 
> #############
> d = data.frame( x = c(154471 , 517423 , 704286 , 236117 , 10664898 ,
> 21887 ,
> 104994 , 794101 , 289567 , 74818 , 63920 , 251053 , 263583 , 84882 ,
> 55075 ,
> 741076 , 92000 , 137799 , 59856 , 184992 , 8292355),
>                    y = c(624 , 1681 , 590 , 2073 , 12189 , 42 , 343 , 365
> ,
> 969 , 108 , 366 , 1664 , 738 , 420 , 318 , 1278 , 887 , 395 , 462 , 1376
> ,
> 17907)
>                  )
> plot(d, log = "xy")
> abline(lm(x ~ y, data = d))
> 
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/abline-is-not-plotting-tp4677583.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!



More information about the R-help mailing list