[R] Matrix-like plot

Martin Maechler maechler at stat.math.ethz.ch
Fri May 31 17:05:13 CEST 2002


>>>>> "GS" == Gavin Simpson <gavin.simpson at ucl.ac.uk> writes:

     < ... >

    GS> What I do not know who to do is to plot the matrix-like plot.  I want to
    GS> have a point for every value greater than zero in the matrix.  So that
    GS> if in sample/row 1, species 1 and 2 were present at 25% and 75%
    GS> respectively but species 3 was absent, I would want 2 points, one for
    GS> each species present scaled relative to their abundance.  I presume what
    GS> I would actually do is plot an expand.grid() object and vary the cex by
    GS> the values in the matrix so that zero values had zero cex, but I am not
    GS> sure how to go about doing this.  

I'd look at 
    sunflowerplot()
    symbols()
and stars()

additionally to image()

    GS> An alternative could be to use image()
    GS> to plot coloured boxes for each cell based on the abundances.  I tried
    GS> this initially like so:

    >> test <- expand.grid(x=1:47, y=1:83)
    >> names(test)
    GS> [1] "x" "y"
    >> image(test, z=cladocera) #cladocera being the matrix containing the
    GS> abundances
    GS> Error in image.default(test, z = cladocera) : 
    GS> increasing x and y values expected

    GS> I am now stuck as to how generate the x and y points for image.

I don't have `cladocera' but the following works

> image(list(x = u, y = v), z=z)
> str(z <- outer(u,v, function(x,y){x <- x-6; sin(x)*exp(-(x/4^2 + (y-20)/3^2))}))
 num [1:10, 1:20]  3.563  2.642 -0.463 -2.801 -2.435 ...
> image(list(x = u, y = v), z=z)

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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