Re: [R] possible bug in image() ??

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Mon 10 Oct 2005 - 17:48:16 EST

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@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



R-help@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 Received on Mon Oct 10 17:50:46 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:34:14 EST