[R] Additional points to scatter plot show up at wrong place

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Fri May 15 17:00:50 CEST 2009


Peter Menzel wrote:
> Hi everyone,
> 
> I have a problem with adding points to scatter plots.
> The plot is drawn with the scatterplot() function from the car library:
> 
> scatterplot(data[,2] ~ data[,1],
> 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)
> 
> after that, I draw one line with abline(0,1,col="gray20") which works
> perfectly fine.
> 
> now I want to add, say the point (0.6,0.6) to the plot with
> points(c(0.6),c(0.6)).
> The point is plotted, but not exactly at the proper coordinates, but
> at something like (0.55,0.55).

scatterplot() is using layout() interńally, so you can't expect this to
work. I don't think there's a nice way of going back to a previous
subregion.

> When I use the plot() function to make the scatter plots, this problem
> does not occur, but I want to have those nice box plots next to the X
> and Y-axes that are drawn by scatterplot()..
> 
> Anybody has an idea how to get the points at the right place in the plot?
> 
> cheers, Peter
> 
> ______________________________________________
> 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.


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907




More information about the R-help mailing list