[R] possible bug in image() ??

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon Oct 10 09:48:16 CEST 2005


I guess what you see is the limited resolution of your screen rather 
than a bug in R.
Try to produce a reliably image, e.g. some pdf file:

pdf("test.pdf")
   cc=runif(n=1500,min=0.1,max=1.2)
   ccc=ceiling(cc-1)
   dd=runif(n=1500,min=0.1,max=1.2)
   ddd=ceiling(dd-1)
   ee=runif(n=1500,min=0.1,max=1.2)
   eee=ceiling(ee-1)
   x=matrix(data=c(ccc,ddd,eee),nrow=1500)
   image(x)
   points(seq(0,1,1/(1500-1)),(ccc)^-1*0, pch=".")
   points(seq(0,1,1/(1500-1)),(ddd)^-1*0.5, pch=".")
   points(seq(0,1,1/(1500-1)),(eee)^-1*1, pch=".")
dev.off()

and zoom in now ....


Uwe Ligges



Gareth Davies wrote:

> Hi everyone. 
> The function image() seems not to be correctly plotting some 
> matrices that I give it. (Iâ€™m using R 2.1.1)   
> The following code creates a matrix (denoted x) with 1500 
> rows and 3 columns, with all entries 0 or 1, and then plots 
> the image of this matrix.
> 
>  cc=runif(n=1500,min=0.1,max=1.2)
>  ccc=ceiling(cc-1)
>  dd=runif(n=1500,min=0.1,max=1.2)
>  ddd=ceiling(dd-1)
>  ee=runif(n=1500,min=0.1,max=1.2)
>  eee=ceiling(ee-1)
>  x=matrix(data=c(ccc,ddd,eee),nrow=1500)
>  image(x)
> 
> ..where the first column in x  (vector ccc) is depicted 
> horizontally along the bottom of the image. However, when I 
> overplot the non-zero elements of the vectors ccc, ddd and 
> eee onto their respective horizontal positions on the 
> image,..
> 
>  points(seq(0,1,1/(1500-1)),(ccc)^-1*0)
> points(seq(0,1,1/(1500-1)),(ddd)^-1*0.5)
>  points(seq(0,1,1/(1500-1)),(eee)^-1*1)
> 
> 
>  â€¦the locations of the 1â€™s in image do not always match the 
> locations of the 1â€™s in ccc,ddd, and eee (although they are 
> mostly correct). Do other people find this problem?? I've 
> tried with other matrices, and the results only seem in 
> error when the matrix is large, say with more than 1000 
> rows. 
> 
> Cheers, Gareth Davies
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list