[R] Additional points to scatter plot show up at wrong place
Stefan Grosse
singularitaet at gmx.net
Fri May 15 16:15:07 CEST 2009
On Fri, 15 May 2009 15:43:33 +0200 Peter Menzel
<pmenzel at googlemail.com> wrote:
PM> scatterplot(data[,2] ~ data[,1],
PM> data=data,smooth=F,reg.line=F,xlim=c(0.5,1),ylim=c(0.5,1),ylab="ML",xlab="Freq",cex.lab=1.9,cex.axis=1.8)
Side remark: you don't need do data[,2] if you have specified data=data
as you did. So var1~var2 would be enough.
PM> after that, I draw one line with abline(0,1,col="gray20") which
PM> works perfectly fine.
abline for me also does not work in the expected way, see below.
PM> now I want to add, say the point (0.6,0.6) to the plot with
PM> points(c(0.6),c(0.6)).
the c() is not necessary points(0.6,0.6) is enough.
PM> The point is plotted, but not exactly at the proper coordinates, but
PM> at something like (0.55,0.55).
That seems to be a bug. The axis seems not to be drawn exactly.
to replicate see:
library(car)
data<-data.frame(x1=rnorm(100),x2=rnorm(100,.25))
scatterplot(x1~x2,data=data,ylab="ML",xlab="Freq")
points(0.5,0.5,col="blue")
abline(h=0.5,lty=2) # check whether point is at the correct location.
abline(v=0.5,lty=2)
abline(h=1) # line is not at 1 at the y-axis!
So maybe one can contact the package owner?
Btw. creating such a plot by yourself is easy, have a look
at ?layout ?axis
Stefan
More information about the R-help
mailing list