[R] image ()

Jeffrey A. Royle royle at bearmtn-e0.cgd.ucar.edu
Thu Dec 3 16:01:43 CET 1998

I had this same question about two days ago and I think I concluded
that the [1,1] element of the matrix is the upper left corner of
the image plot, which is the (1,n) coordinate in the plot space.
The [n,1] element of the matrix is the (1,1) coordinate in the plot
space, the [1,n] element is the (n,n) coordinate and the 
[n,n] element is the (n,1) coordinate.  
This actually makes sense if the grid coordinates are indexed like:
1  5  9  13
2  6  10 14
3  7  11 15
4  8  12 16

which is pretty standard (then points in the data matrix
correspond to the matrix that indexes grid points...or the
ith element of the vec of the data matrix corresponds to the
ith grid point), then the pixels in the image that you view 
are arranged like the grid points. Also, this indexing of
grid points  is convenient for locating the neighbors of any point.

In any case, I had a question about putting a legend on an
image plot.  Can someone give me advice on that?  I was hoping
that a canned legend function exists for image, but it doesn't
appear so.

One other question: Contour does not appear to label contour lines.
Was this a neglected detail, or a feature?


On Thu, 3 Dec 1998, Lorenz Gygax wrote:

> Dear all,
> I am working with R Version 0.62.2  (July 10, 1998) on a SuSE Linux 5.2.
> I have troubles in understanding the function image (). Can someone
> enlighten me?
> I'd like to draw a square image-plot (with every little part of the image
> a square as well) and add some (straight) lines to it. Also, I create an
> empty z matrix which I need to fill step by step. Thus I tried to find out
> how exactly the image squares are fitted into the x-y axis. 
> (in S-plus, one way to do it is to have x and y one integer bigger than
> the dimensions of the z matrix. Thus x and y give the corner coordinates
> of the little image squares. Or, x and y are the same length as the
> dimensions of the z-matrix and then x and y give the center of the image
> squares.) 
> Now I don't really see how it is done in R from the help file thus I did a
> simple example:
> > test.mat <- matrix (1:9, ncol= 3)
> > image (1:3, 1:3, test.matrix)
> > iamge (1:4, 1:4, test.matrix)
> both commands are executed without error.
> BUT the first one splits the two axis at 1.5 and 2.5 (starting at 1 and
> ending at 3) and thus not all the little image squares (or rather
> rectangles) are the same size.
> In the second case, again the image rectangles at the edge are smaller
> than in the center and part of the plot stays empty as there are 16 fields
> but only 9 values in the matrix (no complaint that the axes and the
> dimensions of the matrix don't match).
> If I leave out the x and y (as suggested in the help file) the image looks
> the same as with 1:3, the only difference being that the scale runs from 0
> to 1 (with splits at 0.25 and 0.75). 
> Can I influence this behaviour and how?
> Thank you for your help! Regards,
> --			~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Lorenz Gygax		 LGygax at amath.unizh.ch;       room: 36-L-40
> 			 Department of Applied Mathematics
> 			 University of Zuerich-Irchel
> 			 Winterthurerstr. 190; CH-8057 Zurich
> 			 voice: 41-1-635-58-52  fax: 41-1-635-57-05
> 			~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list